From 73f5d219bb59d2930010220d144bbff22031fb90 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Sat, 22 Dec 2018 17:26:12 +0000 Subject: [PATCH] re PR fortran/88169 (Rejects USE rename of namelist group) 2018-12-21 Steven G. Kargl PR fortran/88169 * module.c (mio_namelist): Remove an error condition/message that is contrary to the Fortran standard. 2018-12-21 Steven G. Kargl PR fortran/88169 * gfortran.dg/pr88169_1.f90: new test. * gfortran.dg/pr88169_2.f90: Ditto. * gfortran.dg/pr88169_3.f90: Ditto. From-SVN: r267351 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/module.c | 12 ---------- gcc/testsuite/ChangeLog | 7 ++++++ gcc/testsuite/gfortran.dg/pr88169_1.f90 | 21 +++++++++++++++++ gcc/testsuite/gfortran.dg/pr88169_2.f90 | 31 +++++++++++++++++++++++++ gcc/testsuite/gfortran.dg/pr88169_3.f90 | 15 ++++++++++++ 6 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr88169_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr88169_2.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr88169_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index e960cc74976..6f37f0954ca 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-12-22 Steven G. Kargl + + PR fortran/88169 + * module.c (mio_namelist): Remove an error condition/message that + is contrary to the Fortran standard. + 2018-12-22 Thomas Koenig PR fortran/85544 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index d42ab4789eb..163b3ceebb2 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -3711,7 +3711,6 @@ static void mio_namelist (gfc_symbol *sym) { gfc_namelist *n, *m; - const char *check_name; mio_lparen (); @@ -3722,17 +3721,6 @@ mio_namelist (gfc_symbol *sym) } else { - /* This departure from the standard is flagged as an error. - It does, in fact, work correctly. TODO: Allow it - conditionally? */ - if (sym->attr.flavor == FL_NAMELIST) - { - check_name = find_use_name (sym->name, false); - if (check_name && strcmp (check_name, sym->name) != 0) - gfc_error ("Namelist %s cannot be renamed by USE " - "association to %s", sym->name, check_name); - } - m = NULL; while (peek_atom () != ATOM_RPAREN) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1dd460aa172..d358d2d3a31 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-12-21 Steven G. Kargl + + PR fortran/88169 + * gfortran.dg/pr88169_1.f90: new test. + * gfortran.dg/pr88169_2.f90: Ditto. + * gfortran.dg/pr88169_3.f90: Ditto. + 2018-12-21 Steven G. Kargl PR fortran/69121 diff --git a/gcc/testsuite/gfortran.dg/pr88169_1.f90 b/gcc/testsuite/gfortran.dg/pr88169_1.f90 new file mode 100644 index 00000000000..6ea4aba5e10 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88169_1.f90 @@ -0,0 +1,21 @@ +! { dg-do run } +module foo_nml + implicit none + real :: x = -1 + namelist /foo/ x +end module + +program main + use foo_nml, only: bar => foo, x + implicit none + integer fd + x = 42 + open(newunit=fd, file='tmp.dat', status='replace') + write(fd,nml=bar) + close(fd) + open(newunit=fd, file='tmp.dat', status='old') + read(fd,nml=bar) + if (x /= 42) stop 1 + close(fd) +end program +! { dg-final { cleanup-modules "foo_nml" } } diff --git a/gcc/testsuite/gfortran.dg/pr88169_2.f90 b/gcc/testsuite/gfortran.dg/pr88169_2.f90 new file mode 100644 index 00000000000..a7805b4557a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88169_2.f90 @@ -0,0 +1,31 @@ +! { dg-do run } +module foo_nml + implicit none + real :: x = -1 + namelist /foo/ x +end module +! +! Yes, implicit typing of local variable 'x'. +! +program main + use foo_nml, only: bar => foo + integer fd + x = 42 + open(newunit=fd, file='tmp.dat', status='replace') + write(fd,nml=bar) + close(fd) + open(newunit=fd, file='tmp.dat', status='old') + read(fd,nml=bar) + close(fd) + call bah + if (x /= 42) stop 1 +end program + +subroutine bah + use foo_nml + integer fd + open(newunit=fd, file='tmp.dat', status='old') + read(fd,nml=foo) + if (x /= -1) stop 2 + close(fd, status='delete') +end subroutine bah diff --git a/gcc/testsuite/gfortran.dg/pr88169_3.f90 b/gcc/testsuite/gfortran.dg/pr88169_3.f90 new file mode 100644 index 00000000000..6bc24ed6b71 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr88169_3.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +module foo_nml + implicit none + real :: x = -1 + namelist /foo/ x +end module + +program main + use foo_nml, only: bar => foo, x + implicit none + real a + namelist /bar/a ! { dg-error "already is USE associated" } +end program +! { dg-final { cleanup-modules "foo_nml" } } -- 2.30.2