This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] fortran/66043 -- Check for NULL() in STORAGE_SIZE()
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 May 2015 07:59:55 -0700
- Subject: [PATCH] fortran/66043 -- Check for NULL() in STORAGE_SIZE()
- Authentication-results: sourceware.org; auth=none
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
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