diff options
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/interface.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/interface_40.f90 | 8 |
4 files changed, 27 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index d29126322a7..0d1607d2ddd 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-01-13 Steven G. Kargl <kargl@gcc.gnu.org> + + Backport from mainline + PR fortran/78814 + * interface.c (symbol_rank): Check for NULL pointer. + 2018-01-10 Steven G. Kargl <kargl@gcc.gnu.org> Backport from trunk diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 6fe0647ecfe..2e5732a8810 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1261,8 +1261,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 77e7915acd9..d104c938e19 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-01-13 Steven G. Kargl <kargl@gcc.gnu.org> + + Backport from mainline + PR fortran/78814 + * gfortran.dg/interface_40.f90: New testcase. + 2018-01-12 Eric Botcazou <ebotcazou@adacore.com> * gcc.c-torture/execute/20180112-1.c: New test. 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 + |