[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-fortran
Subject:    [Committed] PF fortran/71895 -- remove assert
From:       Steve Kargl <sgk () troutmask ! apl ! washington ! edu>
Date:       2016-10-24 19:25:33
Message-ID: 20161024192533.GA39474 () troutmask ! apl ! washington ! edu
[Download RAW message or body]

The following patch was committed to cure an ICE.  The gcc_assert()
is converted into an "if ()" condition where gfc_internal_error()
is called.  gfc_internal_error() allows gfortran to exit gracefully
instead of an ICE, because gfortran has already isssued an error message.

2016-10-24  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/71895
	* interface.c (gfc_compare_derived_types):  Convert gcc_assert()
	to a gfc_internal_error() to prevent an ICE.

2016-10-24  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/71895
	* gfortran.dg/pr71895.f90: New test.

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(revision 241491)
+++ gcc/fortran/interface.c	(working copy)
@@ -615,7 +615,8 @@ gfc_compare_derived_types (gfc_symbol *d
   if (derived1 == derived2)
     return 1;
 
-  gcc_assert (derived1 && derived2);
+  if (!derived1 || !derived2)
+    gfc_internal_error ("gfc_compare_derived_types: invalid derived type");
 
   /* Compare UNION types specially.  */
   if (derived1->attr.flavor == FL_UNION || derived2->attr.flavor == FL_UNION)
Index: gcc/testsuite/gfortran.dg/pr71895.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr71895.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr71895.f90	(working copy)
@@ -0,0 +1,10 @@
+! { dg-do compile }
+program p
+   type t
+      integer :: n
+   end type
+   type(t) :: x
+   class(t) :: y        ! { dg-error "must be dummy, allocatable or pointer" }
+   print *, extends_type_of(x, y)
+   print *, extends_type_of(y, x)
+end

-- 
Steve
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic