public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity
@ 2022-06-04 18:05 kargl at gcc dot gnu.org
2022-06-04 18:08 ` [Bug fortran/105847] " kargl at gcc dot gnu.org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-06-04 18:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
Bug ID: 105847
Summary: namelist-object-name can be a renamed host associated
entity
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: kargl at gcc dot gnu.org
Target Milestone: ---
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
@ 2022-06-04 18:08 ` kargl at gcc dot gnu.org
2022-06-04 18:12 ` kargl at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-06-04 18:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-06-04
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from kargl at gcc dot gnu.org ---
Found via https://groups.google.com/g/comp.lang.fortran/c/CfODg8wnF8M
The following code should compile and execute to completion.
! { 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)
close(10, status='delete')
if (name_in_program /= 123) stop 3
end
The following patch fixes the problem.
diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
index 732221f848b..4621ff1c5b7 100644
--- a/gcc/fortran/trans-io.cc
+++ b/gcc/fortran/trans-io.cc
@@ -1666,8 +1666,10 @@ transfer_namelist_element (stmtblock_t * block, const
char * var_name,
gcc_assert (sym || c);
/* Build the namelist object name. */
-
- string = gfc_build_cstring_const (var_name);
+ if (sym->attr.use_rename)
+ string = gfc_build_cstring_const (sym->ns->use_stmts->rename->local_name);
+ else
+ string = gfc_build_cstring_const (var_name);
string = gfc_build_addr_expr (pchar_type_node, string);
/* Build ts, as and data address using symbol or component. */
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
2022-06-04 18:08 ` [Bug fortran/105847] " kargl at gcc dot gnu.org
@ 2022-06-04 18:12 ` kargl at gcc dot gnu.org
2022-06-05 2:27 ` jvdelisle at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-06-04 18:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
2022-06-04 18:08 ` [Bug fortran/105847] " kargl at gcc dot gnu.org
2022-06-04 18:12 ` kargl at gcc dot gnu.org
@ 2022-06-05 2:27 ` jvdelisle at gcc dot gnu.org
2023-05-30 1:52 ` kargl at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-06-05 2:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jvdelisle at gcc dot gnu.org
CC| |jvdelisle at gcc dot gnu.org
--- Comment #2 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I will see if I can commit this one.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (2 preceding siblings ...)
2022-06-05 2:27 ` jvdelisle at gcc dot gnu.org
@ 2023-05-30 1:52 ` kargl at gcc dot gnu.org
2023-05-30 1:53 ` kargl at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-05-30 1:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #3 from kargl at gcc dot gnu.org ---
Created attachment 55195
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55195&action=edit
dejagnu-ified testcase
Testcase showing the wrong namelist object name ends up in the file.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (3 preceding siblings ...)
2023-05-30 1:52 ` kargl at gcc dot gnu.org
@ 2023-05-30 1:53 ` kargl at gcc dot gnu.org
2023-05-31 2:30 ` jvdelisle at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-05-30 1:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #4 from kargl at gcc dot gnu.org ---
Created attachment 55196
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55196&action=edit
patch that fixes the bug
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (4 preceding siblings ...)
2023-05-30 1:53 ` kargl at gcc dot gnu.org
@ 2023-05-31 2:30 ` jvdelisle at gcc dot gnu.org
2024-02-14 20:02 ` jvdelisle at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2023-05-31 2:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #5 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Hi Steve,I will see if I can get all this tested and committed this coming
weekend.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (5 preceding siblings ...)
2023-05-31 2:30 ` jvdelisle at gcc dot gnu.org
@ 2024-02-14 20:02 ` jvdelisle at gcc dot gnu.org
2024-02-14 21:31 ` jvdelisle at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2024-02-14 20:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #6 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I obviously did not get to this last May. Will try now.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (6 preceding siblings ...)
2024-02-14 20:02 ` jvdelisle at gcc dot gnu.org
@ 2024-02-14 21:31 ` jvdelisle at gcc dot gnu.org
2024-02-14 21:57 ` jvdelisle at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2024-02-14 21:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #7 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Steve, I am getting a boatload of regressions on this. I wonder if something
in the sym structure needs to be guarded here. They appear to be segfaults. Can
you take a look?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (7 preceding siblings ...)
2024-02-14 21:31 ` jvdelisle at gcc dot gnu.org
@ 2024-02-14 21:57 ` jvdelisle at gcc dot gnu.org
2024-02-14 22:38 ` jvdelisle at gcc dot gnu.org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2024-02-14 21:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #8 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
There is an assert just above the patch that implies that sym can be NULL if c
is not. With gdb I checked, and sure enough thats the failure point. I am
testing with sym included in the condition.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (8 preceding siblings ...)
2024-02-14 21:57 ` jvdelisle at gcc dot gnu.org
@ 2024-02-14 22:38 ` jvdelisle at gcc dot gnu.org
2024-02-14 22:43 ` cvs-commit at gcc dot gnu.org
2024-02-15 17:50 ` jvdelisle at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2024-02-14 22:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #9 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
This seems to work:
/* Build the namelist object name. */
-
- string = gfc_build_cstring_const (var_name);
+ if (sym && !sym->attr.use_only && sym->attr.use_rename)
+ string = gfc_build_cstring_const (sym->ns->use_stmts->rename->local_name);
+ else
+ string = gfc_build_cstring_const (var_name);
Evidently the processing of the 'only' takes care of the renaming before we get
here. Without the attr.use_only part namelist_use_only.f90 fails.
With these tweaks there are no regressions and the test case here passes.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (9 preceding siblings ...)
2024-02-14 22:38 ` jvdelisle at gcc dot gnu.org
@ 2024-02-14 22:43 ` cvs-commit at gcc dot gnu.org
2024-02-15 17:50 ` jvdelisle at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-14 22:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <jvdelisle@gcc.gnu.org>:
https://gcc.gnu.org/g:8221201cc59870579b9dc451b173f94b8d8b0993
commit r14-8992-g8221201cc59870579b9dc451b173f94b8d8b0993
Author: Steve Kargl <kargl@gcc.gnu.org>
Date: Wed Feb 14 14:40:16 2024 -0800
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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/105847] namelist-object-name can be a renamed host associated entity
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
` (10 preceding siblings ...)
2024-02-14 22:43 ` cvs-commit at gcc dot gnu.org
@ 2024-02-15 17:50 ` jvdelisle at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2024-02-15 17:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105847
--- Comment #11 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Having done all this, I found:
C8102 (R868) The namelist-group-name shall not be a name accessed by use
association.
What does this mean in the context of renamed?
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-02-15 17:50 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-04 18:05 [Bug fortran/105847] New: namelist-object-name can be a renamed host associated entity kargl at gcc dot gnu.org
2022-06-04 18:08 ` [Bug fortran/105847] " kargl at gcc dot gnu.org
2022-06-04 18:12 ` kargl at gcc dot gnu.org
2022-06-05 2:27 ` jvdelisle at gcc dot gnu.org
2023-05-30 1:52 ` kargl at gcc dot gnu.org
2023-05-30 1:53 ` kargl at gcc dot gnu.org
2023-05-31 2:30 ` jvdelisle at gcc dot gnu.org
2024-02-14 20:02 ` jvdelisle at gcc dot gnu.org
2024-02-14 21:31 ` jvdelisle at gcc dot gnu.org
2024-02-14 21:57 ` jvdelisle at gcc dot gnu.org
2024-02-14 22:38 ` jvdelisle at gcc dot gnu.org
2024-02-14 22:43 ` cvs-commit at gcc dot gnu.org
2024-02-15 17:50 ` jvdelisle at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).