diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2729,6 +2729,10 @@ KnownBase = Bases[idx]; Bases[NumGoodBases++] = Bases[idx]; + if (NewBaseType->isIncompleteType()) { + assert(NewBaseType->isDependentType()); + continue; + } // Note this base's direct & indirect bases, if there could be ambiguity. if (Bases.size() > 1) NoteIndirectBases(Context, IndirectBaseTypes, NewBaseType); diff --git a/clang/test/SemaCXX/base-class-ambiguity-check.cpp b/clang/test/SemaCXX/base-class-ambiguity-check.cpp --- a/clang/test/SemaCXX/base-class-ambiguity-check.cpp +++ b/clang/test/SemaCXX/base-class-ambiguity-check.cpp @@ -7,3 +7,11 @@ // Test that this code no longer causes a crash in Sema. rdar://23291875 struct Derived : Base, T {}; }; + + +template class Foo2 { + struct Base; + + // Should not crash on an incomplete-type base specifier. + struct Derived : Base {}; +}; diff --git a/clang/test/SemaCXX/ms-interface.cpp b/clang/test/SemaCXX/ms-interface.cpp --- a/clang/test/SemaCXX/ms-interface.cpp +++ b/clang/test/SemaCXX/ms-interface.cpp @@ -106,3 +106,10 @@ static_assert(!__is_interface_class(IUnknown), "oops"); static_assert(!__is_interface_class(IFaceStruct), "oops"); static_assert(!__is_interface_class(IFaceInheritsStruct), "oops"); + +template +class TemplateContext { + class Base; + // Should not crash on an incomplete-type base specifier. + __interface Foo : Base {}; +};