https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123810

--- Comment #11 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Created attachment 63656
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63656&action=edit
pr118829.patch

This seems somewhat related to PR118829 which I've been looking at on-and-off
for quite a long time now, and indeed the proposed patch looks not entirely
dissimilar to the patch I've been working on (attached), though that still has
plenty of problems as well (mostly to do with debug info, I'm somewhat lost on
that still).

And indeed modules is not ready for this.  The issue is indeed that we don't
merge the anonymous IMPLICIT_TYPEDEF_P type that got a name for linkage
purposes, because in check_mergeable_decl we only see the typedef decl.  The
following hunk fixed the error for my patch and should be able to adapted for
yours too I'm sure:


diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 5e1ff3d2a30..cd76e1b9a15 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -12118,6 +12118,15 @@ check_mergeable_decl (merge_kind mk, tree decl, tree
ovl, merge_key const &key)
                            == key.ret))
                 found = match;
             }
+          else if (DECL_IMPLICIT_TYPEDEF_P (d_inner)
+                   && TYPE_DECL_NAMES_UNNAMED_P (d_inner))
+            {
+              /* We're looking for the underlying (previously unnamed) type
+                 for a type with a typedef for linkage purposes, but we've
+                 found the typedef.  */
+              found = TYPE_NAME (DECL_ORIGINAL_TYPE (m_inner));
+              gcc_checking_assert (DECL_IMPLICIT_TYPEDEF_P (found));
+            }
           break;

         default:

Reply via email to