diff mbox

[Committed] PF fortran/71895 -- remove assert

Message ID 20161024192533.GA39474@troutmask.apl.washington.edu
State New
Headers show

Commit Message

Steve Kargl Oct. 24, 2016, 7:25 p.m. UTC
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.
diff mbox

Patch

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