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.

llvm-svn: 317073
This commit is contained in:
Richard Trieu 2017-11-01 03:57:27 +00:00
parent c51aac675d
commit 7f932dd063
2 changed files with 16 additions and 3 deletions

View File

@ -2555,9 +2555,8 @@ Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base,
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()))

View File

@ -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'}}
}