]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/82994 (ICE in gfc_match_deallocate, at fortran/match.c:4478)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 7 Feb 2018 22:41:59 +0000 (22:41 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 7 Feb 2018 22:41:59 +0000 (22:41 +0000)
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: r257468

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/deallocate_error_3.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/deallocate_error_4.f90 [new file with mode: 0644]

index 00caf4add6ed8ec8c3e488c679fe2d1063d9f421..c3a2b628d8abf0c7227387545c9a17ecd3c5f966 100644 (file)
@@ -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  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/82049
index d3ea167355433e169b0505c8d96feaa2184a44e2..516abc5ba80e86870b60f6852d3a8377421c1330 100644 (file)
@@ -4275,8 +4275,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);
index 4e8db9407c9ac9686e4740899e763723506c7046..09a8056109cf1fe51cf853ff1e7420387d19e690 100644 (file)
@@ -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  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/82049
diff --git a/gcc/testsuite/gfortran.dg/deallocate_error_3.f90 b/gcc/testsuite/gfortran.dg/deallocate_error_3.f90
new file mode 100644 (file)
index 0000000..149b7c8
--- /dev/null
@@ -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 (file)
index 0000000..c12e776
--- /dev/null
@@ -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