Committed as obvious.
2018-02-07 Steven G. Kargl <[email protected]>
PR fortran/82994
* match.c (gfc_match_deallocate): Check for NULL pointer.
2018-02-07 Steven G. Kargl <[email protected]>
PR fortran/82994
* gfortran.dg/deallocate_error_3.f90: New test.
* gfortran.dg/deallocate_error_4.f90: New test.
--
Steve
Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c (revision 257459)
+++ gcc/fortran/match.c (working copy)
@@ -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: gcc/testsuite/gfortran.dg/deallocate_error_3.f90
===================================================================
--- gcc/testsuite/gfortran.dg/deallocate_error_3.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/deallocate_error_3.f90 (working copy)
@@ -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
Index: gcc/testsuite/gfortran.dg/deallocate_error_4.f90
===================================================================
--- gcc/testsuite/gfortran.dg/deallocate_error_4.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/deallocate_error_4.f90 (working copy)
@@ -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