aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven G. Kargl <kargl@gcc.gnu.org>2018-02-07 22:29:22 +0000
committerSteven G. Kargl <kargl@gcc.gnu.org>2018-02-07 22:29:22 +0000
commitb35a0ccd139f5df8262ef7ea5fed81d88074ecf8 (patch)
tree74651fb9a8d4adeb6578cf8c2e6704247010ee76
parent72267602a7e46a578cf89cfc12782f8740b1cac5 (diff)
downloadgcc-b35a0ccd139f5df8262ef7ea5fed81d88074ecf8.zip
gcc-b35a0ccd139f5df8262ef7ea5fed81d88074ecf8.tar.gz
gcc-b35a0ccd139f5df8262ef7ea5fed81d88074ecf8.tar.bz2
re PR fortran/82994 (ICE in gfc_match_deallocate, at fortran/match.c:4478)
2018-02-07 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/82994 * match.c (gfc_match_deallocate): Check for NULL pointer. 2018-02-07 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/82994 * gfortran.dg/deallocate_error_3.f90: New test. * gfortran.dg/deallocate_error_4.f90: New test. From-SVN: r257465
-rw-r--r--gcc/fortran/ChangeLog5
-rw-r--r--gcc/fortran/match.c4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/deallocate_error_3.f909
-rw-r--r--gcc/testsuite/gfortran.dg/deallocate_error_4.f9010
5 files changed, 32 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 7dbb9c1..a87c48a 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-07 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/82994
+ * match.c (gfc_match_deallocate): Check for NULL pointer.
+
2018-02-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/68560
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 7bce34b..9313f43 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -4632,8 +4632,8 @@ gfc_match_deallocate (void)
&& (tail->expr->ref->type == REF_COMPONENT
|| tail->expr->ref->type == REF_ARRAY));
if (sym && sym->ts.type == BT_CLASS)
- b2 = !(CLASS_DATA (sym)->attr.allocatable
- || CLASS_DATA (sym)->attr.class_pointer);
+ b2 = !(CLASS_DATA (sym) && (CLASS_DATA (sym)->attr.allocatable
+ || CLASS_DATA (sym)->attr.class_pointer));
else
b2 = sym && !(sym->attr.allocatable || sym->attr.pointer
|| sym->attr.proc_pointer);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 24a99a5..6d82e4e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-07 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/82994
+ * gfortran.dg/deallocate_error_3.f90: New test.
+ * gfortran.dg/deallocate_error_4.f90: New test.
+
2018-02-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/68560
diff --git a/gcc/testsuite/gfortran.dg/deallocate_error_3.f90 b/gcc/testsuite/gfortran.dg/deallocate_error_3.f90
new file mode 100644
index 0000000..149b7c8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/deallocate_error_3.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/82994
+! Code contributed by Gerhard Steinmetz
+program p
+ type t
+ end type
+ class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+ deallocate (x) ! { dg-error "not a nonprocedure pointer nor an allocatable" }
+end
diff --git a/gcc/testsuite/gfortran.dg/deallocate_error_4.f90 b/gcc/testsuite/gfortran.dg/deallocate_error_4.f90
new file mode 100644
index 0000000..c12e776
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/deallocate_error_4.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR fortran/82994
+! Code contributed by Gerhard Steinmetz
+program p
+ type t
+ end type
+ class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+ allocate (x) ! { dg-error "neither a data pointer nor an allocatable" }
+ deallocate (x) ! { dg-error "not a nonprocedure pointer nor an allocatable" }
+end