diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/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); diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp b/clang/unittests/AST/StructuralEquivalenceTest.cpp --- a/clang/unittests/AST/StructuralEquivalenceTest.cpp +++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp @@ -976,6 +976,12 @@ EXPECT_FALSE(testStructuralMatch(t)); } +TEST_F(StructuralEquivalenceTemplateTest, DependentFieldDecl) { + const char *Code = "template 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 struct foo {explicit(b) foo(int);};",