]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/78814 (ICE in symbol_rank, at fortran/interface.c:1265)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 13 Jan 2018 19:12:32 +0000 (19:12 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Sat, 13 Jan 2018 19:12:32 +0000 (19:12 +0000)
2012-01-13  Steven G. Kargl  <kargl@gcc.gnu.org>

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

2012-01-13  Steven G. Kargl  <kargl@gcc.gnu.org>

Backport from mainline
        PR fortran/78814
        * gfortran.dg/interface_40.f90: New testcase.

From-SVN: r256647

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

index cd2be3fecdcceaaec5cc8b15c6a228a9bb222ca6..ccad53b1b86bebc7e70c3a9c9966ebfc1552ef0d 100644 (file)
@@ -1,3 +1,9 @@
+2018-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
index 6b2cf103011b68513d650c5ca55e5870c543a633..6dac80195bd25e34baff071e0a3cfe5c38f8d2f7 100644 (file)
@@ -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;
 }
 
index 300e93dcf504dc3bcf4b365d42c74907de571d3a..a4e1004640f64b3055bca96b6a3028321e8edee9 100644 (file)
@@ -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-10  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        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 (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
+