public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "aldot at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-103931-4-lnZF52DWzh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103931-4@http.gcc.gnu.org/bugzilla/>

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)

  parent reply	other threads:[~2023-04-24 16:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 15:39 [Bug fortran/103931] New: " trnka at scm dot com
2022-01-06 16:55 ` [Bug fortran/103931] " marxin at gcc dot gnu.org
2022-01-06 21:40 ` anlauf at gcc dot gnu.org
2022-01-06 22:38 ` pinskia at gcc dot gnu.org
2022-01-06 22:42 ` pinskia at gcc dot gnu.org
2022-01-06 22:50 ` trnka at scm dot com
2022-01-06 22:54 ` pinskia at gcc dot gnu.org
2022-01-06 22:55 ` pinskia at gcc dot gnu.org
2022-01-07  7:03 ` marxin at gcc dot gnu.org
2023-03-31 20:12 ` anlauf at gcc dot gnu.org
2023-04-01 19:50 ` aldot at gcc dot gnu.org
2023-04-02 15:54 ` aldot at gcc dot gnu.org
2023-04-02 18:59 ` anlauf at gcc dot gnu.org
2023-04-12 17:20 ` aldot at gcc dot gnu.org
2023-04-12 18:56 ` anlauf at gcc dot gnu.org
2023-04-13 19:59 ` aldot at gcc dot gnu.org
2023-04-14 17:21 ` aldot at gcc dot gnu.org
2023-04-24 16:17 ` aldot at gcc dot gnu.org
2023-04-24 16:29 ` aldot at gcc dot gnu.org [this message]
2023-04-24 20:14 ` anlauf at gcc dot gnu.org
2023-04-25 18:16 ` anlauf at gcc dot gnu.org
2023-04-25 18:46 ` aldot at gcc dot gnu.org
2023-04-25 19:03 ` anlauf at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103931-4-lnZF52DWzh@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).