r322438 - [Sema] Fix crash for type-dependent base classes
Jan Korous via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 13 07:24:17 PST 2018
Author: jkorous
Date: Sat Jan 13 07:24:16 2018
New Revision: 322438
URL: http://llvm.org/viewvc/llvm-project?rev=322438&view=rev
Log:
[Sema] Fix crash for type-dependent base classes
Added:
cfe/trunk/test/SemaCXX/base-class-ambiguity-check.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=322438&r1=322437&r2=322438&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Jan 13 07:24:16 2018
@@ -2417,9 +2417,16 @@ bool Sema::AttachBaseSpecifiers(CXXRecor
// 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();
Added: cfe/trunk/test/SemaCXX/base-class-ambiguity-check.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/base-class-ambiguity-check.cpp?rev=322438&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/base-class-ambiguity-check.cpp (added)
+++ cfe/trunk/test/SemaCXX/base-class-ambiguity-check.cpp Sat Jan 13 07:24:16 2018
@@ -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 {};
+};
More information about the cfe-commits
mailing list