]> granicus.if.org Git - clang/commitdiff
Replace a cast with a dyn_cast as suggested by Doug.
authorAnders Carlsson <andersca@mac.com>
Sat, 30 May 2009 17:26:39 +0000 (17:26 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 30 May 2009 17:26:39 +0000 (17:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72624 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInherit.cpp
test/SemaCXX/abstract.cpp

index 1eccc1f193fbad8b7e5f83b4802f9389196fb27a..1b968f0fbccef8fa2c002457b8c52cac4c7aca42 100644 (file)
@@ -195,13 +195,14 @@ bool Sema::LookupInBases(CXXRecordDecl *Class,
       Paths.ScratchPath.Decls = 
         BaseRecord->lookup(Context, Criteria.Method->getDeclName());
       while (Paths.ScratchPath.Decls.first != Paths.ScratchPath.Decls.second) {
-        CXXMethodDecl *MD = 
-          cast<CXXMethodDecl>(*Paths.ScratchPath.Decls.first);
-
-        OverloadedFunctionDecl::function_iterator MatchedDecl;
-        if (MD->isVirtual() && !IsOverload(Criteria.Method, MD, MatchedDecl)) {
-          FoundPathToThisBase = true;
-          break;
+        if (CXXMethodDecl *MD = 
+              dyn_cast<CXXMethodDecl>(*Paths.ScratchPath.Decls.first)) {
+          OverloadedFunctionDecl::function_iterator MatchedDecl;
+          if (MD->isVirtual() && 
+              !IsOverload(Criteria.Method, MD, MatchedDecl)) {
+            FoundPathToThisBase = true;
+            break;
+          }
         }
         
         ++Paths.ScratchPath.Decls.first;
index cf7322156fa2028a4028e2fb67e4e03fbc614197..dc764da5322b57da7f4bd1b91a4b647034a98a64 100644 (file)
@@ -118,3 +118,11 @@ void foo(void)
        B b;
 }
 
+struct K {
+ int f;
+ virtual ~K();
+};
+
+struct L : public K {
+ void f();
+};