re PR fortran/66043 (ICE on storage_size of null or output of null array)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Mon, 18 May 2015 21:52:03 +0000 (21:52 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Mon, 18 May 2015 21:52:03 +0000 (21:52 +0000)
2015-05-18  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-18  Steven G. Kargl  <kargl@gcc.gnu.org>

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

From-SVN: r223320

gcc/fortran/ChangeLog
gcc/fortran/check.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/storage_size_6.f90 [new file with mode: 0644]

index 1c66684ecbe3770a46662bf26fe51b450026a508..9da169462b791f0ebd1376092d1d07a503022f97 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/66043
+       * gfortran.dg/storage_size_6.f90: New tests.
+
 2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/66040
index 3e0ce5c86249862ed603e19b1c8ad213fc93ac86..a6ba549f2962fe8e8d3326366707eee3af29fa33 100644 (file)
@@ -6243,6 +6243,15 @@ 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 ("Intrinsic function NULL at %L cannot be an actual "
+                "argument to STORAGE_SIZE, because it returns a "
+                "disassociated pointer", &a->where);
+      return false;
+    }
+
   if (a->ts.type == BT_ASSUMED)
     {
       gfc_error ("%qs argument of %qs intrinsic at %L shall not be TYPE(*)",
index 38f7ac1c2a82a7ac8fdba5301a0376fbbd966792..bda83a50ed93c3099bfa3705d51554f23cef945c 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/66043
+       * gfortran.dg/storage_size_6.f90: New tests.
+
 2015-05-18  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/66040
diff --git a/gcc/testsuite/gfortran.dg/storage_size_6.f90 b/gcc/testsuite/gfortran.dg/storage_size_6.f90
new file mode 100644 (file)
index 0000000..5038292
--- /dev/null
@@ -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 "cannot be an actual" }
+end