Here's another small, obvious fix where a pointer was not
to see that it was non-NULL. Committed after regression
testing on x86_64-*-freebsd.
2017-11-09 Steven G. Kargl <[email protected]>
PR fortran/78814
* interface.c (symbol_rank): Check for NULL pointer.
2017-11-09 Steven G. Kargl <[email protected]>
PR fortran/78814
* gfortran.dg/interface_40.f90: New testcase.
--
Steve
Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c (revision 254554)
+++ gcc/fortran/interface.c (working copy)
@@ -1262,8 +1262,13 @@ generic_correspondence (gfc_formal_arglist *f1, gfc_fo
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;
}
Index: gcc/testsuite/gfortran.dg/interface_40.f90
===================================================================
--- gcc/testsuite/gfortran.dg/interface_40.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/interface_40.f90 (working copy)
@@ -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
+