From 1fb84d5b0a2dcdb8fd5aa39680df651811d55fbb Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Thu, 9 Nov 2017 18:45:29 +0000 Subject: [PATCH] re PR fortran/78814 (ICE in symbol_rank, at fortran/interface.c:1265) 2017-11-09 Steven G. Kargl PR fortran/78814 * interface.c (symbol_rank): Check for NULL pointer. 2017-11-09 Steven G. Kargl PR fortran/78814 * gfortran.dg/interface_40.f90: New testcase. From-SVN: r254604 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/interface.c | 9 +++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/interface_40.f90 | 8 ++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/interface_40.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 6c9f246d64e..9be20c889a1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2017-11-09 Steven G. Kargl + + PR fortran/78814 + * interface.c (symbol_rank): Check for NULL pointer. + 2017-11-08 Steven G. Kargl PR Fortran/82841 diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 9f0fcc82f24..1b7ebf56b92 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1262,8 +1262,13 @@ generic_correspondence (gfc_formal_arglist *f1, gfc_formal_arglist *f2, static int symbol_rank (gfc_symbol *sym) { - gfc_array_spec *as; - as = (sym->ts.type == BT_CLASS) ? CLASS_DATA (sym)->as : sym->as; + gfc_array_spec *as = NULL; + + if (sym->ts.type == BT_CLASS && CLASS_DATA (sym) && CLASS_DATA (sym)->as) + as = CLASS_DATA (sym)->as; + else + as = sym->as; + return as ? as->rank : 0; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a38d19f72c3..7ee000b07de 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-09 Steven G. Kargl + + PR fortran/78814 + * gfortran.dg/interface_40.f90: New testcase. + 2017-11-09 Eric Botcazou * gnat.dg/controlled2.adb, gnat.dg/controlled4.adb, diff --git a/gcc/testsuite/gfortran.dg/interface_40.f90 b/gcc/testsuite/gfortran.dg/interface_40.f90 new file mode 100644 index 00000000000..085c6b30f39 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_40.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/78814 +! Code contributed by Gerhard Steinmetz +program p + class(*) :: x ! { dg-error " must be dummy, allocatable or pointer" } + print *, f(x) +end + -- 2.30.2