From: Harald Anlauf Date: Wed, 18 Dec 2019 16:34:06 +0000 (+0000) Subject: re PR fortran/70853 (ICE on pointing to null, in gfc_add_block_to_block, at fortran... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6573d760cdfec1b4577b268ce1ff19cecc4c9cbd;p=gcc.git re PR fortran/70853 (ICE on pointing to null, in gfc_add_block_to_block, at fortran/trans.c:1599) 2019-12-18 Harald Anlauf 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 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f8103bb9d8c..b3a5b0d9a57 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-12-18 Harald Anlauf + + PR fortran/70853 + * trans-expr.c (gfc_trans_pointer_assignment): Reject bounds + remapping if pointer target is NULL(). + 2019-12-12 Harald Anlauf PR fortran/92898 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index fe89c7b02ed..eb3250a6ab3 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index df1299dc9bf..942448061cb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-18 Harald Anlauf + + PR fortran/70853 + * gfortran.dg/pr70853.f90: New test. + 2019-12-18 Martin Jambor PR ipa/92971 diff --git a/gcc/testsuite/gfortran.dg/pr70853.f90 b/gcc/testsuite/gfortran.dg/pr70853.f90 new file mode 100644 index 00000000000..9ae44ccb823 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr70853.f90 @@ -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