From: Richard Trieu Date: Wed, 1 Nov 2017 03:57:27 +0000 (+0000) Subject: Change assertion to quick exit from checking function. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bcfd8ea6e72cf5f685c1a682bd29464e3fb47762;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317073 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index fa9e9f3218..a5ccce6154 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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())) diff --git a/test/SemaCXX/missing-members.cpp b/test/SemaCXX/missing-members.cpp index 96bed074db..61dddcbe50 100644 --- a/test/SemaCXX/missing-members.cpp +++ b/test/SemaCXX/missing-members.cpp @@ -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'}} +}