From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D96CF3857702; Mon, 24 Apr 2023 16:29:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D96CF3857702 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682353774; bh=lbKlw2knlOQZtFtdG5JhthO9wLbJyux2EK+zxBhVZEU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aZDVOcdXToR/8D5sfxFokNBfgk0cBQ8VN12JbiupfoY7WD7IKY7rhExzbVWYSMblU 8hg0Q3oGN2jbomOj5Kv03qMU0t+UICh2JrVB8CeCWRevhrRJmkg7vPZsLfEszSqd0J w4jflZ5ly1hXxKR6lDaL9b+6e3xTrWX25Ifdnm74= From: "aldot at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/103931] Type name "c_ptr" is ambiguous when iso_c_binding is imported both directly and indirectly Date: Mon, 24 Apr 2023 16:29:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: aldot at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103931 --- Comment #18 from Bernhard Reutner-Fischer --- (In reply to Bernhard Reutner-Fischer from comment #17) > (In reply to Bernhard Reutner-Fischer from comment #16) >=20 > > 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. >=20 > 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 =3D 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 =3D 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)=