This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Committed] PF fortran/71895 -- remove assert
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 24 Oct 2016 12:25:33 -0700
- Subject: [Committed] PF fortran/71895 -- remove assert
- Authentication-results: sourceware.org; auth=none
- Reply-to: kargl at uw dot edu
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