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:29:22 +0000 (22:29 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 7 Feb 2018 22:29:22 +0000 (22:29 +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: r257465

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 7dbb9c1984918b0bad37bff124be536e8f39ce2a..a87c48a3ff863fdb4df55a6bd86434fd29f1aa98 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  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/68560
index 7bce34b56a0196c232f6ac9d29e63cb66b16775b..9313f435ffb93686658ba1e6170a26fd827e9b35 100644 (file)
@@ -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);
index 24a99a58ecd8bc3230097c24355aa97313709b56..6d82e4e2d746a6805a9eba3d37be68412a2e6c3c 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  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 (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