r317073 - Change assertion to quick exit from checking function.
Richard Trieu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 31 20:57:27 PDT 2017
Author: rtrieu
Date: Tue Oct 31 20:57:27 2017
New Revision: 317073
URL: http://llvm.org/viewvc/llvm-project?rev=317073&view=rev
Log:
Change assertion to quick exit from checking function.
Remove the assertion that could be triggered by invalid code. Replace it with
an early exit from the checking function.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/missing-members.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=317073&r1=317072&r2=317073&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Oct 31 20:57:27 2017
@@ -2555,9 +2555,8 @@ Sema::CheckDerivedToBaseConversion(QualT
CXXBasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true,
/*DetectVirtual=*/false);
bool DerivationOkay = IsDerivedFrom(Loc, Derived, Base, Paths);
- assert(DerivationOkay &&
- "Can only be used with a derived-to-base conversion");
- (void)DerivationOkay;
+ if (!DerivationOkay)
+ return true;
const CXXBasePath *Path = nullptr;
if (!Paths.isAmbiguous(Context.getCanonicalType(Base).getUnqualifiedType()))
Modified: cfe/trunk/test/SemaCXX/missing-members.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/missing-members.cpp?rev=317073&r1=317072&r2=317073&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/missing-members.cpp (original)
+++ cfe/trunk/test/SemaCXX/missing-members.cpp Tue Oct 31 20:57:27 2017
@@ -37,3 +37,17 @@ struct S : A::B::C {
using A::B::C::f; // expected-error {{no member named 'f' in 'A::B::C'}}
};
+
+struct S1 {};
+
+struct S2 : S1 {};
+
+struct S3 : S2 {
+ void run();
+};
+
+struct S4: S3 {};
+
+void test(S4 *ptr) {
+ ptr->S1::run(); // expected-error {{no member named 'run' in 'S1'}}
+}
More information about the cfe-commits
mailing list