Hello world,

I have just committed the attached patch as obvious and simple
as r279180.

The ICE for the test case occurred because a previous error
had left the derived field of the typespec NULL. Just returning
"invalid type" or "invalid class" in such a case is enough
to cure the ICE.

Regards

        Thomas

2019-12-10  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/92863
        * misc.c (gfc_typename): If derived component is NULL for
        derived or class, return "invalid type" or "invalid class",
        respectively.

2019-12-10  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/92863
        * gfortran.dg/interface_45.f90: New test.

Index: misc.c
===================================================================
--- misc.c	(Revision 279064)
+++ misc.c	(Arbeitskopie)
@@ -164,9 +164,19 @@ gfc_typename (gfc_typespec *ts)
       sprintf (buffer, "UNION(%s)", ts->u.derived->name);
       break;
     case BT_DERIVED:
+      if (ts->u.derived == NULL)
+	{
+	  sprintf (buffer, "invalid type");
+	  break;
+	}
       sprintf (buffer, "TYPE(%s)", ts->u.derived->name);
       break;
     case BT_CLASS:
+      if (ts->u.derived == NULL)
+	{
+	  sprintf (buffer, "invalid class");
+	  break;
+	}
       ts1 = ts->u.derived->components ? &ts->u.derived->components->ts : NULL;
       if (ts1 && ts1->u.derived && ts1->u.derived->attr.unlimited_polymorphic)
 	sprintf (buffer, "CLASS(*)");
! { dg-do compile }
! PR 92863 - this used to ICE
! Test case by Arseny Solokha.

type(l1) function mp() ! { dg-error "type for function" }
  call sub(mp) ! { dg-error "Type mismatch" }
end function mp

function bi(ry)
  call sub(ry) ! { dg-error "Type mismatch" }
end function bi

Reply via email to