diff options
author | Richard Trieu <rtrieu@google.com> | 2017-11-01 03:57:27 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2017-11-01 03:57:27 +0000 |
commit | bcfd8ea6e72cf5f685c1a682bd29464e3fb47762 (patch) | |
tree | d7e5abfd7b9ef82d286a28a3e49bdb8f14cd9c84 | |
parent | dd478afe4c5a4f486cc2bcdb0974f4ac001532b1 (diff) | |
download | clang-bcfd8ea6e72cf5f685c1a682bd29464e3fb47762.tar.gz |
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
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/missing-members.cpp | 14 |
2 files changed, 16 insertions, 3 deletions
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'}} +} |