https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88169
kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kargl at gcc dot gnu.org --- Comment #2 from kargl at gcc dot gnu.org --- (In reply to kargl from comment #1) > Fortran 95 contains > > NOTE 11.8 > > The constraints in sections 5.5.1, 5.5.2, and 5.4 prohibit the local-name > from appearing as a common-block-object in a COMMON statement, an > equivalence- > object in an EQUIVALENCE statement, or a namelist-group-name in a NAMELIST > statement, respectively. There is no prohibition against the local-name > appearing as a common-block-name or a namelist-object. > > This appears to prohibit > > program main > use foo_nml, only: bar => foo > namelist /bah/ bar ! <-- Invalid > x = 42 > write(*,nml=bar) > end program > > So, I do believe you are correct. Your code is conforming. Hmmm, upon further reading of F95 and checking the code, one finds /* 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); } F95 contains Constraint: The namelist-group-name shall not be a name made accessible by use association. The code is definitely non-conforming by this constraint. Note 11.8 is a red herring. It deals with a namelist-group-objects not a namelist-group-name. Now, looking at F2018, one has C8102 (R868) The namelist-group-name shall not be a name accessed by use association. Your code is invalid. What does ifort and NAG report if you request strict adherence to the Fortran standard. I suppose that one could argue that the renaming of the namelist group name 'foo' to 'bar' prevents 'foo' from being accessible, but 'foo' had to be accessible to permit the renaming to occur.