]> granicus.if.org Git - clang/commitdiff
Change assertion to quick exit from checking function.
authorRichard Trieu <rtrieu@google.com>
Wed, 1 Nov 2017 03:57:27 +0000 (03:57 +0000)
committerRichard Trieu <rtrieu@google.com>
Wed, 1 Nov 2017 03:57:27 +0000 (03:57 +0000)
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

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/missing-members.cpp

index fa9e9f3218122a7148b1da79b31e1ac19ae7e1d4..a5ccce615429505fb6d5c4e2eee9fdd42981fcb5 100644 (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()))
index 96bed074db857352f3384d5c202b2bfa793441b1..61dddcbe5026b7e0f0fda7c65c09d0456606be13 100644 (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'}}
+}