aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg
diff options
context:
space:
mode:
authorSteve Kargl <kargl@gcc.gnu.org>2024-02-14 14:40:16 -0800
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2024-02-14 14:42:19 -0800
commit8221201cc59870579b9dc451b173f94b8d8b0993 (patch)
tree1ab6592592bc2fef16217a9218fe0438b9a991f7 /gcc/testsuite/gfortran.dg
parent430c772be3382134886db33133ed466c02efc71c (diff)
downloadgcc-8221201cc59870579b9dc451b173f94b8d8b0993.zip
gcc-8221201cc59870579b9dc451b173f94b8d8b0993.tar.gz
gcc-8221201cc59870579b9dc451b173f94b8d8b0993.tar.bz2
Fortran: namelist-object-name renaming.
PR fortran/105847 gcc/fortran/ChangeLog: * trans-io.cc (transfer_namelist_element): When building the namelist object name, if the use rename attribute is set, use the local name specified in the use statement. gcc/testsuite/ChangeLog: * gfortran.dg/pr105847.f90: New test.
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
-rw-r--r--gcc/testsuite/gfortran.dg/pr105847.f9039
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/pr105847.f90 b/gcc/testsuite/gfortran.dg/pr105847.f90
new file mode 100644
index 0000000..9a89d39
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr105847.f90
@@ -0,0 +1,39 @@
+! { dg-do run }
+module m
+ integer :: name_in_module = 123
+end module
+
+program foo
+
+ use m, name_in_program => name_in_module
+ namelist /nl/ name_in_program
+
+ if (name_in_program /= 123) stop 1
+
+ open(unit=10, file='fort.10', status='replace')
+ write(10,nl)
+ close(10)
+
+ name_in_program = 42
+ if (name_in_program /= 42) stop 2
+
+ open(unit=10, file='fort.10', status='old')
+ read(10,nl)
+ if (name_in_program /= 123) stop 3
+ close(10)
+
+ call bar
+
+ contains
+
+ subroutine bar
+ integer name_in_program
+ namelist /nl/ name_in_program
+ name_in_program = 0
+ open(unit=10, file='fort.10', status='old')
+ read(10,nl)
+ if (name_in_program /= 123) stop 4
+ close(10,status='delete')
+ end subroutine bar
+
+end