From b5fd86aba81ec7dbd50e588909f81771841c03bd Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Sat, 21 Dec 2019 20:25:43 +0000 Subject: [PATCH] =?utf8?q?re=20PR=20fortran/92990=20(INVALID=20code=20with?= =?utf8?q?=20NULLIFY=20=E2=80=93=20partially=20misleading=20error=20messag?= =?utf8?q?e=20"If=20bounds=20remapping=20is=20specified=20at=20(1),=20the?= =?utf8?q?=20pointer=20target=20shall=20not=20be=20NULL")?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2019-12-21 Harald Anlauf 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 | 6 ++++++ gcc/fortran/match.c | 17 +++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr92990.f90 | 12 ++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr92990.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index dee20f6fdee..63a6de616b4 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-12-21 Harald Anlauf + + PR fortran/92990 + * match.c (gfc_match_nullify): Check for valid pointer object. + Reject bounds remapping. + 2019-12-21  Paul Thomas   PR fortran/92753 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index d3e3abcb700..b467d99b1a4 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1f1dec5c480..0068dc0cf20 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-21 Harald Anlauf + + PR fortran/92990 + * gfortran.dg/pr92990.f90: New test. + 2019-12-21  Paul Thomas   PR fortran/92753 diff --git a/gcc/testsuite/gfortran.dg/pr92990.f90 b/gcc/testsuite/gfortran.dg/pr92990.f90 new file mode 100644 index 00000000000..a996715684e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr92990.f90 @@ -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 -- 2.30.2