Message ID | 016801d81e66$10d48410$327d8c30$@nextmovesoftware.com |
---|---|
State | New |
Headers | show |
Series | gfortran: Respect target's NO_DOT_IN_LABEL in trans-common.cc | expand |
On 10.02.22 11:07, Roger Sayle wrote: > The fix is to tweak trans-common.cc to respect the target's NO_DOT_IN_LABEL > (and NO_DOLLAR_IN_LABEL) when generating internal equiv.%d symbols. In general, I think the patch is okay – but as '_' is a valid identifier and with -fdollar-ok '$' is valid as well, I wonder whether there should be a prefix and/or a capital letter. Namely: +#if !defined (NO_DOT_IN_LABEL) +#define GFC_EQUIV_FMT "equiv.%d" +#elif !defined (NO_DOLLAR_IN_LABEL) +#define GFC_EQUIV_FMT "equiv$%d" +#else +#define GFC_EQUIV_FMT "equiv_%d" +#endif The first one we want to keep as is for backwards compatibility. And the '.' is fine in this regard. But I think for the other two, we need to do more, e.g., '_Equiv' + '$%d' / '_%d'. The '_' and capital letter should place everything into the compiler namespace (in terms of C/C++) and Fortran itself requires for a name (case insensitive, lower cased by gfortran): [A-Z][A-Z0-9_]* – thus, '_E' contains two characters not accessible in a normal Fortran program (ignoring bind(C,name="..."). If the _Equiv[_$]%d sounds sensible to you: Please change; if not, what concerns do you have? > Ok for mainline? OK with changing the prefix for the non-dot variant. Tobias > 2022-02-10 Roger Sayle <roger@nextmovesoftware.com> > > gcc/fortran/ChangeLog > * trans-common.cc (GFC_EQUIV_FMT): New macro respecting the > target's NO_DOT_IN_LABEL and NO_DOLLAR_IN_LABEL preferences. > (build_equiv_decl): Use GFC_EQUIV_FMT here. ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
diff --git a/gcc/fortran/trans-common.cc b/gcc/fortran/trans-common.cc index 7b4d198..184a976 100644 --- a/gcc/fortran/trans-common.cc +++ b/gcc/fortran/trans-common.cc @@ -338,6 +338,13 @@ build_field (segment_info *h, tree union_type, record_layout_info rli) h->field = field; } +#if !defined (NO_DOT_IN_LABEL) +#define GFC_EQUIV_FMT "equiv.%d" +#elif !defined (NO_DOLLAR_IN_LABEL) +#define GFC_EQUIV_FMT "equiv$%d" +#else +#define GFC_EQUIV_FMT "equiv_%d" +#endif /* Get storage for local equivalence. */ @@ -356,7 +363,7 @@ build_equiv_decl (tree union_type, bool is_init, bool is_saved, bool is_auto) return decl; } - snprintf (name, sizeof (name), "equiv.%d", serial++); + snprintf (name, sizeof (name), GFC_EQUIV_FMT, serial++); decl = build_decl (input_location, VAR_DECL, get_identifier (name), union_type); DECL_ARTIFICIAL (decl) = 1;