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

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -11399,6 +11400,22 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, return {}; } +QualType ASTContext::mergeTagTypes(QualType LHS, QualType RHS) { AaronBallman wrote: I'm following the naming convention already used by ot

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

2025-04-07 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,41 @@ class StmtComparer { }; } // namespace +static bool +CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context, + const Decl *D1, const Decl *D2, + const Decl *Prim

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

2025-04-07 Thread Erich Keane via cfe-commits
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-04-07 Thread Erich Keane via cfe-commits
@@ -450,6 +453,41 @@ class StmtComparer { }; } // namespace +static bool +CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context, + const Decl *D1, const Decl *D2, + const Decl *Prim

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

2025-04-07 Thread Erich Keane via cfe-commits
@@ -11399,6 +11400,22 @@ static QualType mergeEnumWithInteger(ASTContext &Context, const EnumType *ET, return {}; } +QualType ASTContext::mergeTagTypes(QualType LHS, QualType RHS) { erichkeane wrote: So this isn't really merging the TYPES, more merging tag

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

2025-04-07 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: Ping https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-04-05 Thread Shafik Yaghmour via cfe-commits
@@ -1849,8 +1852,9 @@ TEST_F(StructuralEquivalenceCacheTest, ReturnStmtNonEq) { Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false);

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

2025-04-05 Thread Shafik Yaghmour via cfe-commits
@@ -1913,8 +1919,9 @@ TEST_F(StructuralEquivalenceCacheTest, Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false); + get<0>(TU)-

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

2025-04-04 Thread via cfe-commits
Sirraide wrote: > Yeah, there's a fair amount of moving parts. This is why I want to go with > the most conservative approach of rejecting unless the attributes are the > same. That seems reasonable given that we can always make this more permissive later on. https://github.com/llvm/llvm-pro

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

2025-04-04 Thread Martin Uecker via cfe-commits
uecker wrote: > > Once that is settled, then go back to work on redeclaration/definition > support. Possibly it'd be good to pause and ask the standards body to clarify > how it's supposed to work first. While I think my proposed semantics above > make sense, the standard doesn't actually _sp

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

2025-04-04 Thread Martin Uecker via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-04-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-03-31 Thread James Y Knight via cfe-commits
jyknight wrote: Just to say again, I think the discussion may be crisper if we consider this as two entirely-distinct features: 1. An expansion of "compatible type" for purposes of pointer casts/non-UB/etc. 2. The ability to provide two definitions of the same struct type in the same scope, to

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

2025-03-31 Thread Martin Uecker via cfe-commits
uecker wrote: > Curiously, GCC doesn't merge the standard attributes either, it seems to do > last-one-wins: https://godbolt.org/z/j3W7ej5Kq I filed a bug for this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119526 https://github.com/llvm/llvm-project/pull/132939

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

2025-03-31 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: > However, we do have some prior art -- we're not inventing the whole idea of > decl-merging from scratch right now. So maybe we can follow that prior art? > For example, top-level attributes on a struct's definition can be inherited > from a declaration in the same scope.

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

2025-03-29 Thread Shafik Yaghmour via cfe-commits
@@ -1886,8 +1891,9 @@ TEST_F(StructuralEquivalenceCacheTest, VarDeclWithDifferentStorageClassNoEq) { Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::D

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

2025-03-29 Thread Martin Uecker via cfe-commits
uecker wrote: > I now see there's two different parts of the problem to worry about: > > First case: A redeclaration in a _different_ scope. This always defines a new > distinct type. This was valid before C23, and is still valid regardless of > whether the type is compatible. (In contrast wit

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

2025-03-28 Thread James Y Knight via cfe-commits
jyknight wrote: I now see there's two different parts of the problem to worry about: First case: A redeclaration in a _different_ scope. This always defines a new distinct type. This was valid before C23, and is still valid regardless of whether the type is compatible. (In contrast with functi

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-27 Thread Martin Uecker via cfe-commits
uecker wrote: Another comment about attributes: Attributes should not generally affect type compatibility (in general, but also relevant for this feature) for two reasons: 1. Standard attributes are ignorable, and this would then break. 2. Compatibility affects aliasing, one one certainly does

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

2025-03-27 Thread James Y Knight via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-27 Thread Martin Uecker via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-27 Thread Martin Uecker via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-27 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-27 Thread Martin Uecker via cfe-commits
uecker wrote: BTW: I did not push for this feature to be exposed in earlier language modes because GCC will ship with GNU C23 by default with GCC 15. GCC 15 already saw distribution-wide testing in Redhat and Debian and from this experience I do not expect any problems related to this featur

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

2025-03-27 Thread Martin Uecker via cfe-commits
uecker wrote: > It seems to me that we could simplify the implementation by being a bit more > literal in the interpretation of the requirements: look only at the type, > alignment, name, and bitfield-width of members. Just don't bother checking > other stuff > > I'd hope it can look more lik

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

2025-03-26 Thread James Y Knight via cfe-commits
jyknight wrote: It seems to me that we could simplify the implementation by being a bit more literal in the interpretation of the requirements: look only at the type, alignment, name, and bitfield-width of members. Just don't bother checking other stuff I'd hope it can look more like a simple

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,472 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -1454,6 +1567,12 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, QualType Owner2Type) { const auto *Owner2 = cast(Field2->getDeclContext()); + // In C23 mode, check for structural equivalence of attribu

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 9b1f905b483a2b42e4681bbef42b2641f8ccf5ad 2bde3a9c6eb5e23b0e9274122bd6f9a50ffa3bc4 --e

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -1496,9 +1615,37 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return false; } - if (Field1->isBitField()) -return IsStructurallyEquivalent(Context, Field1->getBitWidth(), -Field2->getBitWidth(

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -43,6 +43,9 @@ struct StructuralEquivalenceContext { /// key: (from, to, IgnoreTemplateParmDepth) using NonEquivalentDeclSet = llvm::DenseSet>; + /// The language options to use for making a structural equivalence check. + const LangOptions &LangOpts; + --

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,472 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,472 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -1496,9 +1615,37 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return false; } - if (Field1->isBitField()) -return IsStructurallyEquivalent(Context, Field1->getBitWidth(), -Field2->getBitWidth(

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -1496,9 +1615,37 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return false; } - if (Field1->isBitField()) -return IsStructurallyEquivalent(Context, Field1->getBitWidth(), -Field2->getBitWidth(

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread Aaron Ballman via cfe-commits
@@ -478,16 +478,24 @@ def warn_odr_function_type_inconsistent : Warning< "external function %0 declared with incompatible types in different " "translation units (%1 vs. %2)">, InGroup; +def err_odr_attr_inconsistent : Error< + "attribute %0 is incompatible%select{| in d

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

2025-03-26 Thread via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread via cfe-commits
@@ -43,6 +43,9 @@ struct StructuralEquivalenceContext { /// key: (from, to, IgnoreTemplateParmDepth) using NonEquivalentDeclSet = llvm::DenseSet>; + /// The language options to use for making a structural equivalence check. + const LangOptions &LangOpts; + --

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

2025-03-26 Thread via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are

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

2025-03-26 Thread via cfe-commits
@@ -1454,6 +1567,12 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, QualType Owner2Type) { const auto *Owner2 = cast(Field2->getDeclContext()); + // In C23 mode, check for structural equivalence of attribu

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,472 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,472 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: Second round of comments, I may make a third go around but I wouldn't wait for me. https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -0,0 +1,472 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -1964,8 +1972,9 @@ TEST_F(StructuralEquivalenceCacheTest, SpecialNonEq) { Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false); +

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -4567,8 +4567,9 @@ namespace { Reader.getOwningModuleFile(Cat)) { StructuralEquivalenceContext::NonEquivalentDeclSet NonEquivalentDecls; StructuralEquivalenceContext Ctx( - Cat->getASTContext(), Existing->getASTCo

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
https://github.com/shafik commented: A lot of nits https://github.com/llvm/llvm-project/pull/132939 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -156,11 +158,11 @@ struct StructuralEquivalenceTest : ::testing::Test { StructuralEquivalenceContext::NonEquivalentDeclSet NonEquivalentDecls01; StructuralEquivalenceContext::NonEquivalentDeclSet NonEquivalentDecls10; StructuralEquivalenceContext Ctx01( -

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -2003,8 +2012,9 @@ TEST_F(StructuralEquivalenceCacheTest, Cycle) { Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false); + ge

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -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 bei

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -2080,9 +2090,9 @@ TEST_F(StructuralEquivalenceCacheTest, TemplateParmDepth) { EXPECT_FALSE(isInNonEqCache(std::make_pair(NonEqDecl0, NonEqDecl1), true)); StructuralEquivalenceContext Ctx_IgnoreTemplateParmDepth( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTCo

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -1826,8 +1828,9 @@ TEST_F(StructuralEquivalenceCacheTest, SimpleNonEq) { Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false); +

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -1868,8 +1872,9 @@ TEST_F(StructuralEquivalenceCacheTest, VarDeclNoEq) { Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false); +

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -1932,8 +1939,9 @@ TEST_F(StructuralEquivalenceCacheTest, VarDeclWithInitNoEq) { Lang_CXX03); StructuralEquivalenceContext Ctx( - get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(), - NonEquivalentDecls, StructuralEquivalenceKind::Default, false, fa

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

2025-03-25 Thread Shafik Yaghmour via cfe-commits
@@ -9089,8 +9089,8 @@ bool Sema::hasStructuralCompatLayout(Decl *D, Decl *Suggested) { // FIXME: Add a specific mode for C11 6.2.7/1 in StructuralEquivalenceContext // and isolate from other C++ specific checks. StructuralEquivalenceContext Ctx( - D->getASTContext()

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

2025-03-25 Thread Timm Baeder via cfe-commits
@@ -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 bei

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

2025-03-25 Thread via cfe-commits
@@ -0,0 +1,456 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-25 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,456 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-25 Thread via cfe-commits
@@ -0,0 +1,456 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-25 Thread Aaron Ballman via cfe-commits
@@ -0,0 +1,456 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c23 -pedantic -Wall -Wno-comment -verify=both,c23 %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -pedantic -Wall -Wno-comment -Wno-c23-extensions -verify=both,c17 %s + +/* WG14 N3037: + * Improved tag compatibility + * + *

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

2025-03-25 Thread via cfe-commits
@@ -1905,54 +2073,84 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, // Compare the definitions of these two enums. If either or both are // incomplete (i.e. forward declared), we assume that they are equivalent. + // In C23, the order of t

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

2025-03-25 Thread via cfe-commits
@@ -450,6 +453,116 @@ class StmtComparer { }; } // namespace +static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, + const Attr *Attr1, const Attr *Attr2) { + // Two attributes are structurally equivalent if they are