diff options
author | Jan Korous <jkorous@apple.com> | 2018-01-13 15:24:16 +0000 |
---|---|---|
committer | Jan Korous <jkorous@apple.com> | 2018-01-13 15:24:16 +0000 |
commit | fda9daeb032b12d97cd96ca9863ebbd036c0d159 (patch) | |
tree | 7f35b7d4b49525b3e1a822fb01e0a435536c8e09 | |
parent | 0a80f8924b137513c42338760c8e9289bebe6747 (diff) | |
download | bcm5719-llvm-fda9daeb032b12d97cd96ca9863ebbd036c0d159.tar.gz bcm5719-llvm-fda9daeb032b12d97cd96ca9863ebbd036c0d159.zip |
[Sema] Fix crash for type-dependent base classes
llvm-svn: 322438
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/base-class-ambiguity-check.cpp | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index f0a176b14cf..6873feb7802 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2417,9 +2417,16 @@ bool Sema::AttachBaseSpecifiers(CXXRecordDecl *Class, // Attach the remaining base class specifiers to the derived class. Class->setBases(Bases.data(), NumGoodBases); + // Check that the only base classes that are duplicate are virtual. for (unsigned idx = 0; idx < NumGoodBases; ++idx) { // Check whether this direct base is inaccessible due to ambiguity. QualType BaseType = Bases[idx]->getType(); + + // Skip all dependent types in templates being used as base specifiers. + // Checks below assume that the base specifier is a CXXRecord. + if (BaseType->isDependentType()) + continue; + CanQualType CanonicalBase = Context.getCanonicalType(BaseType) .getUnqualifiedType(); diff --git a/clang/test/SemaCXX/base-class-ambiguity-check.cpp b/clang/test/SemaCXX/base-class-ambiguity-check.cpp new file mode 100644 index 00000000000..fc1c4c2cea5 --- /dev/null +++ b/clang/test/SemaCXX/base-class-ambiguity-check.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics + +template <typename T> class Foo { + struct Base : T {}; + + // Test that this code no longer causes a crash in Sema. rdar://23291875 + struct Derived : Base, T {}; +}; |