[clang] [C++20] [Modules] merge the type for anony enum from import and #include (PR #214121)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 7 07:35:50 PDT 2026


================
@@ -2667,6 +2667,22 @@ void Sema::MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New,
       else
         New->setTypeSourceInfo(OldTD->getTypeSourceInfo());
 
+      // An anonymous enum is recognized as a redeclaration only when its typedef
+      // name gets merged, at which point two distinct enum types already exist.
+      // Retype the new enumerators to the old enum type, matching the typedef
+      // merge above; otherwise the merged typedef and its enumerators disagree
+      // on the type (GH213299).
+      //
+      // FIXME: The global module restriction only limits the impact of this
+      // change; relax it if the issue shows up in other contexts.
+      if (Module *M = OldTag->getOwningModule(); M && M->isGlobalModule())
----------------
erichkeane wrote:

this top level (and probably the new tag) needs curleys.

https://github.com/llvm/llvm-project/pull/214121


More information about the cfe-commits mailing list