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.