[clang] [C23] Implement WG14 N3037 (PR #132939)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 25 09:59:37 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, false /*StrictTypeSpelling*/,
+ false /*Complain*/, true /*ErrorOnTagTypeMismatch*/);
+ return Ctx.IsEquivalent(LHS, RHS) ? LHS : QualType{};
----------------
tbaederr wrote:
```suggestion
StructuralEquivalenceContext Ctx(
getLangOpts(), *this, *this, NonEquivalentDecls,
StructuralEquivalenceKind::Default, /*StrictTypeSpelling=*/false,
/*Complain=*/false, /*ErrorOnTagTypeMismatch=*/true);
return Ctx.IsEquivalent(LHS, RHS) ? LHS : QualType{};
```
https://github.com/llvm/llvm-project/pull/132939
More information about the cfe-commits
mailing list