re PR fortran/92990 (INVALID code with NULLIFY – partially misleading error message...
authorHarald Anlauf <anlauf@gmx.de>
Sat, 21 Dec 2019 20:25:43 +0000 (20:25 +0000)
committerHarald Anlauf <anlauf@gcc.gnu.org>
Sat, 21 Dec 2019 20:25:43 +0000 (20:25 +0000)
2019-12-21  Harald Anlauf  <anlauf@gmx.de>

PR fortran/92990
* match.c (gfc_match_nullify): Check for valid pointer object.
Reject bounds remapping.

PR fortran/92990
* gfortran.dg/pr92990.f90: New test.

From-SVN: r279698

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

index dee20f6fdee4749afed8729dc035513817663eef..63a6de616b4035d8b1fd36d191dc46c98e22b8f4 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-21  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/92990
+       * match.c (gfc_match_nullify): Check for valid pointer object.
+       Reject bounds remapping.
+
 2019-12-21  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/92753
index d3e3abcb700f3fe374b1b18a7945739f60531fce..b467d99b1a46c9f1a47c1ff3bceaa7df00e6c487 100644 (file)
@@ -4588,6 +4588,23 @@ gfc_match_nullify (void)
          goto cleanup;
        }
 
+      /* Check for valid array pointer object.  Bounds remapping is not
+        allowed with NULLIFY.  */
+      if (p->ref)
+       {
+         gfc_ref *remap = p->ref;
+         for (; remap; remap = remap->next)
+           if (!remap->next && remap->type == REF_ARRAY
+               && remap->u.ar.type != AR_FULL)
+             break;
+         if (remap)
+           {
+             gfc_error ("NULLIFY does not allow bounds remapping for "
+                        "pointer object at %C");
+             goto cleanup;
+           }
+       }
+
       /* build ' => NULL() '.  */
       e = gfc_get_null_expr (&gfc_current_locus);
 
index 1f1dec5c4804bd71304e11bcf801ea3279a04557..0068dc0cf20e2f2e214b1f4a30fb2c531aac71bc 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-21  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/92990
+       * gfortran.dg/pr92990.f90: New test.
+
 2019-12-21  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/92753
diff --git a/gcc/testsuite/gfortran.dg/pr92990.f90 b/gcc/testsuite/gfortran.dg/pr92990.f90
new file mode 100644 (file)
index 0000000..a996715
--- /dev/null
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/92990
+! Verify fix of error message for NULLIFY vs. pointer assignment (PR70853)
+program p
+  integer, pointer :: x(:)
+  type t
+     integer, pointer :: y(:)
+  end type t
+  type(t) :: z
+  nullify (x(1:2)) ! { dg-error "does not allow bounds remapping" }
+  nullify (z%y(:)) ! { dg-error "does not allow bounds remapping" }
+end