public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [Committed] PR fortran/82994 -- Check for a NULL pointer
@ 2018-02-07 22:30 Steve Kargl
  0 siblings, 0 replies; only message in thread
From: Steve Kargl @ 2018-02-07 22:30 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 328 bytes --]

Committed as obvious.

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.

-- 
Steve

[-- Attachment #2: pr82994.diff --]
[-- Type: text/x-diff, Size: 1873 bytes --]

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-07 22:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-07 22:30 [Committed] PR fortran/82994 -- Check for a NULL pointer Steve Kargl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).