re PR fortran/92863 (ICE in gfc_typename)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 10 Dec 2019 18:31:33 +0000 (18:31 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Tue, 10 Dec 2019 18:31:33 +0000 (18:31 +0000)
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.

From-SVN: r279180

gcc/fortran/ChangeLog
gcc/fortran/misc.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/interface_45.f90 [new file with mode: 0644]

index 86a1a148c5d4282730d44e0b1c166309d82cbe8b..b34a684a3b5092de0dcc3d9b8789f386be4d622e 100644 (file)
@@ -1,3 +1,10 @@
+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  Tobias Burnus  <tobias@codesourcery.com>
 
        PR fortran/92872
index 97df9eea94e15c2e04d2e998761b6ec6c892bc55..3ea8285f753e8dbc5fded606e4631223bcaf2085 100644 (file)
@@ -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(*)");
index 4e52f2a48b2b76dbfe7f6746d41ddd2cf93c520b..39e5366c366e3d8efdedaee749b47b30f5ea76fe 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/92863
+       * gfortran.dg/interface_45.f90: New test.
+
 2019-12-10  Richard Sandiford  <richard.sandiford@arm.com>
 
        * gcc.target/aarch64/sve/mixed_size_7.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/interface_45.f90 b/gcc/testsuite/gfortran.dg/interface_45.f90
new file mode 100644 (file)
index 0000000..095aef6
--- /dev/null
@@ -0,0 +1,11 @@
+! { 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