public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] fortran/66043 -- Check for NULL() in STORAGE_SIZE()
@ 2015-05-15 15:03 Steve Kargl
  2015-05-15 15:37 ` FX
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Kargl @ 2015-05-15 15:03 UTC (permalink / raw)
  To: fortran, gcc-patches

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

Regression tested on trunk. OK to commit? 

The patch shuold be self-explanatory.

2015-05-XX  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66043
	* check.c (gfc_check_storage_size): Prevent the direct use of NULL()
	in STORAGE_SIZE() reference.

2015-05-XX  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/66043
	* gfortran.dg/storage_size_6.f90: New tests.

-- 
Steve

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

Index: gcc/fortran/check.c
===================================================================
--- gcc/fortran/check.c	(revision 223094)
+++ gcc/fortran/check.c	(working copy)
@@ -6243,6 +6243,17 @@ gfc_check_and (gfc_expr *i, gfc_expr *j)
 bool
 gfc_check_storage_size (gfc_expr *a, gfc_expr *kind)
 {
+
+  if (a->expr_type == EXPR_NULL)
+    {
+      gfc_error ("%qs argument of %qs intrinsic at %L shall not be an "
+		 "unallocated allocatable variable or a disassociated or "
+		 "undefined pointer",
+		 gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic,
+		 &a->where);
+      return false;
+    }
+
   if (a->ts.type == BT_ASSUMED)
     {
       gfc_error ("%qs argument of %qs intrinsic at %L shall not be TYPE(*)",
Index: gcc/testsuite/gfortran.dg/storage_size_6.f90
===================================================================
--- gcc/testsuite/gfortran.dg/storage_size_6.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/storage_size_6.f90	(working copy)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/66043
+!
+! Original code from Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+program p
+   print *, storage_size(null()) ! { dg-error "shall not be an unallocated" }
+end

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-15 16:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-15 15:03 [PATCH] fortran/66043 -- Check for NULL() in STORAGE_SIZE() Steve Kargl
2015-05-15 15:37 ` FX
2015-05-15 16:03   ` Steve Kargl
2015-05-15 16:23     ` FX

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).