From: Steven G. Kargl Date: Sat, 13 Jan 2018 19:12:32 +0000 (+0000) Subject: backport: re PR fortran/78814 (ICE in symbol_rank, at fortran/interface.c:1265) X-Git-Tag: releases/gcc-6.5.0~588 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d697510dafa424fea0159859924732f9d50ff51;p=thirdparty%2Fgcc.git backport: re PR fortran/78814 (ICE in symbol_rank, at fortran/interface.c:1265) 2012-01-13 Steven G. Kargl Backport from mainline PR fortran/78814 * interface.c (symbol_rank): Check for NULL pointer. 2012-01-13 Steven G. Kargl Backport from mainline PR fortran/78814 * gfortran.dg/interface_40.f90: New testcase. From-SVN: r256647 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index cd2be3fecdcc..ccad53b1b86b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-01-13 Steven G. Kargl + + Backport from mainline + PR fortran/78814 + * interface.c (symbol_rank): Check for NULL pointer. + 2018-01-10 Steven G. Kargl Backport from trunk diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index 6b2cf103011b..6dac80195bd2 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -1,5 +1,5 @@ /* Deal with interfaces. - Copyright (C) 2000-2016 Free Software Foundation, Inc. + Copyright (C) 2000-2016,2018 Free Software Foundation, Inc. Contributed by Andy Vaught This file is part of GCC. @@ -1165,8 +1165,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 300e93dcf504..a4e1004640f6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-01-13 Steven G. Kargl + + Backport from mainline + PR fortran/78814 + * gfortran.dg/interface_40.f90: New testcase. + 2018-01-10 Steven G. Kargl Backport from trunk diff --git a/gcc/testsuite/gfortran.dg/interface_40.f90 b/gcc/testsuite/gfortran.dg/interface_40.f90 new file mode 100644 index 000000000000..085c6b30f394 --- /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 +