summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>2018-01-13 18:58:56 +0000
committerkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>2018-01-13 18:58:56 +0000
commit49aba91bc4cb7106a07791e4c185c96d96ef71e1 (patch)
tree947f3ed9212916cff54ca8932ef09f1811e77c7d
parent2c05e5f6e0d2f0a1d79a9d71dcd32274e44f5db7 (diff)
downloadgcc-49aba91bc4cb7106a07791e4c185c96d96ef71e1.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@256646 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/interface.c9
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/interface_40.f908
4 files changed, 27 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index d29126322a7..0d1607d2ddd 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2012-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
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 6fe0647ecfe..2e5732a8810 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1261,8 +1261,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 77e7915acd9..d104c938e19 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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-12 Eric Botcazou <ebotcazou@adacore.com>
* gcc.c-torture/execute/20180112-1.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/interface_40.f90 b/gcc/testsuite/gfortran.dg/interface_40.f90
new file mode 100644
index 00000000000..085c6b30f39
--- /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
+