[PATCH] D113474: [clang] Don't crash on an incomplete-type base specifier in template context.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 9 02:15:33 PST 2021
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113474.385745.patch
Type: text/x-patch
Size: 1645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211109/5814e23b/attachment.bin>
More information about the cfe-commits
mailing list