diff mbox series

[committed] Fix PR fortran/78814

Message ID 20171109184725.GA56134@troutmask.apl.washington.edu
State New
Headers show
Series [committed] Fix PR fortran/78814 | expand

Commit Message

Steve Kargl Nov. 9, 2017, 6:47 p.m. UTC
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  <kargl@gcc.gnu.org>

	PR fortran/78814
	* interface.c (symbol_rank): Check for NULL pointer.

2017-11-09  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/78814
	* gfortran.dg/interface_40.f90: New testcase.
diff mbox series

Patch

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
+