[clang] [C23] Implement WG14 N3037 (PR #132939)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 25 14:17:08 PDT 2025


================
@@ -11432,6 +11433,22 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET,
   return {};
 }
 
+QualType ASTContext::mergeTagTypes(QualType LHS, QualType RHS) {
+  // C17 and earlier and C++ disallow two tag definitions within the same TU
+  // from being compatible.
+  if (LangOpts.CPlusPlus || !LangOpts.C23)
+    return {};
+
+  // C23, on the other hand, requires the members to be "the same enough", so
+  // we use a structural equivalence check.
+  StructuralEquivalenceContext::NonEquivalentDeclSet NonEquivalentDecls;
+  StructuralEquivalenceContext Ctx(
+      getLangOpts(), *this, *this, NonEquivalentDecls,
+      StructuralEquivalenceKind::Default, /*StrictTypeSpelling*/ false,
+      /*Complain*/ false, /*ErrorOnTagTypeMismatch*/ true);
----------------
shafik wrote:

```suggestion
      StructuralEquivalenceKind::Default, /*StrictTypeSpelling=*/false,
      /*Complain=*/false, /*ErrorOnTagTypeMismatch*=/true);
```

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


More information about the cfe-commits mailing list