re PR fortran/78814 (ICE in symbol_rank, at fortran/interface.c:1265)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 9 Nov 2017 18:45:29 +0000 (18:45 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 9 Nov 2017 18:45:29 +0000 (18:45 +0000)
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.

From-SVN: r254604

gcc/fortran/ChangeLog
gcc/fortran/interface.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/interface_40.f90 [new file with mode: 0644]

index 6c9f246..9be20c8 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78814
+       * interface.c (symbol_rank): Check for NULL pointer.
+
 2017-11-08  Steven G. Kargl  <kargl@kgcc.gnu.org>
 
        PR Fortran/82841
index 9f0fcc8..1b7ebf5 100644 (file)
@@ -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;
 }
 
index a38d19f..7ee000b 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-09  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78814
+       * gfortran.dg/interface_40.f90: New testcase.
+
 2017-11-09  Eric Botcazou  <ebotcazou@adacore.com>
 
        * 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 (file)
index 0000000..085c6b3
--- /dev/null
@@ -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
+