hokein created this revision. hokein added a reviewer: sammccall. hokein requested review of this revision. Herald added a project: clang.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D113474 Files: clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/base-class-ambiguity-check.cpp clang/test/SemaCXX/ms-interface.cpp Index: clang/test/SemaCXX/ms-interface.cpp =================================================================== --- clang/test/SemaCXX/ms-interface.cpp +++ 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<typename> +class TemplateContext { + class Base; + // Should not crash on an incomplete-type base specifier. + __interface Foo : Base {}; +}; Index: clang/test/SemaCXX/base-class-ambiguity-check.cpp =================================================================== --- clang/test/SemaCXX/base-class-ambiguity-check.cpp +++ 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 <typename T> class Foo2 { + struct Base; + + // Should not crash on an incomplete-type base specifier. + struct Derived : Base {}; +}; Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ 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);
Index: clang/test/SemaCXX/ms-interface.cpp =================================================================== --- clang/test/SemaCXX/ms-interface.cpp +++ 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<typename> +class TemplateContext { + class Base; + // Should not crash on an incomplete-type base specifier. + __interface Foo : Base {}; +}; Index: clang/test/SemaCXX/base-class-ambiguity-check.cpp =================================================================== --- clang/test/SemaCXX/base-class-ambiguity-check.cpp +++ 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 <typename T> class Foo2 { + struct Base; + + // Should not crash on an incomplete-type base specifier. + struct Derived : Base {}; +}; Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ 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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits