re PR fortran/70853 (ICE on pointing to null, in gfc_add_block_to_block, at fortran...
authorHarald Anlauf <anlauf@gmx.de>
Wed, 18 Dec 2019 16:34:06 +0000 (16:34 +0000)
committerHarald Anlauf <anlauf@gcc.gnu.org>
Wed, 18 Dec 2019 16:34:06 +0000 (16:34 +0000)
2019-12-18  Harald Anlauf  <anlauf@gmx.de>

PR fortran/70853
* trans-expr.c (gfc_trans_pointer_assignment): Reject bounds
remapping if pointer target is NULL().

PR fortran/70853
* gfortran.dg/pr70853.f90: New test.

From-SVN: r279527

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr70853.f90 [new file with mode: 0644]

index f8103bb9d8cbff96bea8f982faeca8813f9de6e5..b3a5b0d9a579b821d73221c128627f442d9a1c8f 100644 (file)
@@ -1,3 +1,9 @@
+2019-12-18  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/70853
+       * trans-expr.c (gfc_trans_pointer_assignment): Reject bounds
+       remapping if pointer target is NULL().
+
 2019-12-12  Harald Anlauf  <anlauf@gmx.de>
 
        PR fortran/92898
index fe89c7b02edd75aa572063345b8ebd0833d4d12f..eb3250a6ab380cc8ec714410237b163e0c2545c3 100644 (file)
@@ -9218,6 +9218,13 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
          break;
       rank_remap = (remap && remap->u.ar.end[0]);
 
+      if (remap && expr2->expr_type == EXPR_NULL)
+       {
+         gfc_error ("If bounds remapping is specified at %L, "
+                    "the pointer target shall not be NULL", &expr1->where);
+         return NULL_TREE;
+       }
+
       gfc_init_se (&lse, NULL);
       if (remap)
        lse.descriptor_only = 1;
index df1299dc9bf0c4695724fb6b8236d93e49984b6f..942448061cb4d115793fb44f7145f505f8ce225f 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-18  Harald Anlauf  <anlauf@gmx.de>
+
+       PR fortran/70853
+       * gfortran.dg/pr70853.f90: New test.
+
 2019-12-18  Martin Jambor  <mjambor@suse.cz>
 
        PR ipa/92971
diff --git a/gcc/testsuite/gfortran.dg/pr70853.f90 b/gcc/testsuite/gfortran.dg/pr70853.f90
new file mode 100644 (file)
index 0000000..9ae44cc
--- /dev/null
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/70853
+! Contributed by Gerhard Steinmetz
+program p
+   real, pointer :: z(:)
+   z(1:2) => null() ! { dg-error "pointer target shall not be NULL" }
+   z(2:1) => null() ! { dg-error "pointer target shall not be NULL" }
+end