https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103931
--- Comment #18 from Bernhard Reutner-Fischer <aldot at gcc dot gnu.org> --- (In reply to Bernhard Reutner-Fischer from comment #17) > (In reply to Bernhard Reutner-Fischer from comment #16) > > > I'm testing a more elaborate test which keeps check_for_ambiguous in the > > same spot as before, but in that check, looks if the symtree (C_ptr in this > > case, number 3) is listed in the generic interfaces after the existing check > > that looks if the symbol itself is GENERIC. > > This highlights cases like in use_24.f90 and use_27.f90 and requires > follow-up changes that i'm not entirely comfortable with. We can just mark the dt symbol (which is used to describe the generic interface) as attr.generic = 1 This regtests cleanly and fixes the reported bug. diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index 221165d6dac..28ed1a32b9e 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -4977,6 +4986,10 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s, if (!tmp_sym->attr.function && !gfc_add_function (&tmp_sym->attr, tmp_sym->name, NULL)) return NULL; + + /* Mark the derived-type symbol in the generic interface + as generic. */ + dt_sym->attr.generic = 1; } /* Say what module this symbol belongs to. */ i.e. it marks the dt as GENERIC, so the gmodule contents from comment #16 become ... (('c_funptr' '__iso_c_binding' 2) ('c_ptr' '__iso_c_binding' 3)) // generic interfaces ... (2 'C_funptr' '__iso_c_binding' '' 1 ((DERIVED UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 GENERIC IS_BIND_C IS_C_INTEROP PRIVATE_COMP) ((4 'c_address' (INTEGER 8 0 1 0 INTEGER ()) () () () ( UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE ())) PRIVATE (DERIVED 2 0 1 1 VOID ()) 0 0 () () 0 () () () 2 44 0) 3 'C_ptr' '__iso_c_binding' '' 1 ((DERIVED UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 GENERIC IS_BIND_C IS_C_INTEROP PRIVATE_COMP) ((5 'c_address' (INTEGER 8 0 1 0 INTEGER ()) () () () (UNKNOWN-FL UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) PRIVATE ())) PRIVATE ( DERIVED 3 0 1 1 VOID ()) 0 0 () () 0 () () () 2 42 0)