martong created this revision. martong added reviewers: balazske, teemperor, shafik, a_sidorin. Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs. Herald added a reviewer: a.sidorin. Herald added a project: clang. martong requested review of this revision.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D88665 Files: clang/lib/AST/ASTStructuralEquivalence.cpp clang/unittests/AST/StructuralEquivalenceTest.cpp Index: clang/unittests/AST/StructuralEquivalenceTest.cpp =================================================================== --- clang/unittests/AST/StructuralEquivalenceTest.cpp +++ clang/unittests/AST/StructuralEquivalenceTest.cpp @@ -976,6 +976,12 @@ EXPECT_FALSE(testStructuralMatch(t)); } +TEST_F(StructuralEquivalenceTemplateTest, DependentFieldDecl) { + const char *Code = "template <class T> class foo { int a : sizeof(T); };"; + auto t = makeNamedDecls(Code, Code, Lang_CXX03); + EXPECT_TRUE(testStructuralMatch(t)); +} + TEST_F(StructuralEquivalenceTemplateTest, ExplicitBoolSame) { auto Decls = makeNamedDecls( "template <bool b> struct foo {explicit(b) foo(int);};", Index: clang/lib/AST/ASTStructuralEquivalence.cpp =================================================================== --- clang/lib/AST/ASTStructuralEquivalence.cpp +++ clang/lib/AST/ASTStructuralEquivalence.cpp @@ -1280,6 +1280,10 @@ } if (Field1->isBitField()) { + bool isVD1 = Field1->getBitWidth()->isValueDependent(); + bool isVD2 = Field2->getBitWidth()->isValueDependent(); + if (isVD1 || isVD2) + return isVD1 && isVD2; // Make sure that the bit-fields are the same length. unsigned Bits1 = Field1->getBitWidthValue(Context.FromCtx); unsigned Bits2 = Field2->getBitWidthValue(Context.ToCtx);
Index: clang/unittests/AST/StructuralEquivalenceTest.cpp =================================================================== --- clang/unittests/AST/StructuralEquivalenceTest.cpp +++ clang/unittests/AST/StructuralEquivalenceTest.cpp @@ -976,6 +976,12 @@ EXPECT_FALSE(testStructuralMatch(t)); } +TEST_F(StructuralEquivalenceTemplateTest, DependentFieldDecl) { + const char *Code = "template <class T> class foo { int a : sizeof(T); };"; + auto t = makeNamedDecls(Code, Code, Lang_CXX03); + EXPECT_TRUE(testStructuralMatch(t)); +} + TEST_F(StructuralEquivalenceTemplateTest, ExplicitBoolSame) { auto Decls = makeNamedDecls( "template <bool b> struct foo {explicit(b) foo(int);};", Index: clang/lib/AST/ASTStructuralEquivalence.cpp =================================================================== --- clang/lib/AST/ASTStructuralEquivalence.cpp +++ clang/lib/AST/ASTStructuralEquivalence.cpp @@ -1280,6 +1280,10 @@ } if (Field1->isBitField()) { + bool isVD1 = Field1->getBitWidth()->isValueDependent(); + bool isVD2 = Field2->getBitWidth()->isValueDependent(); + if (isVD1 || isVD2) + return isVD1 && isVD2; // Make sure that the bit-fields are the same length. unsigned Bits1 = Field1->getBitWidthValue(Context.FromCtx); unsigned Bits2 = Field2->getBitWidthValue(Context.ToCtx);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits