diff mbox series

[fortran,committed] Fix PR 92863, 'ICE in gfc_typename

Message ID 45f4fd37-d504-32a8-82b7-beaf1d812fde@netcologne.de
State New
Headers show
Series [fortran,committed] Fix PR 92863, 'ICE in gfc_typename | expand

Commit Message

Thomas Koenig Dec. 10, 2019, 6:37 p.m. UTC
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  <tkoenig@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  <tkoenig@gcc.gnu.org>

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

Patch

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(*)");