From f812dfe8e09a2fed68c74d36e3c9b9f1d8d59c68 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Tue, 10 Dec 2019 18:31:33 +0000 Subject: [PATCH] re PR fortran/92863 (ICE in gfc_typename) 2019-12-10 Thomas Koenig 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 PR fortran/92863 * gfortran.dg/interface_45.f90: New test. From-SVN: r279180 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/misc.c | 10 ++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/interface_45.f90 | 11 +++++++++++ 4 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/interface_45.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 86a1a148c5d..b34a684a3b5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2019-12-10 Thomas Koenig + + 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 PR fortran/92872 diff --git a/gcc/fortran/misc.c b/gcc/fortran/misc.c index 97df9eea94e..3ea8285f753 100644 --- a/gcc/fortran/misc.c +++ b/gcc/fortran/misc.c @@ -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(*)"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4e52f2a48b2..39e5366c366 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-10 Thomas Koenig + + PR fortran/92863 + * gfortran.dg/interface_45.f90: New test. + 2019-12-10 Richard Sandiford * 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 index 00000000000..095aef60186 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_45.f90 @@ -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