From f89bb0fa8b2b806b0a3ad23619c1f5acb4aa952a Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 30 May 2009 17:26:39 +0000 Subject: [PATCH] Replace a cast with a dyn_cast as suggested by Doug. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72624 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaInherit.cpp | 15 ++++++++------- test/SemaCXX/abstract.cpp | 8 ++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/Sema/SemaInherit.cpp b/lib/Sema/SemaInherit.cpp index 1eccc1f193..1b968f0fbc 100644 --- a/lib/Sema/SemaInherit.cpp +++ b/lib/Sema/SemaInherit.cpp @@ -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(*Paths.ScratchPath.Decls.first); - - OverloadedFunctionDecl::function_iterator MatchedDecl; - if (MD->isVirtual() && !IsOverload(Criteria.Method, MD, MatchedDecl)) { - FoundPathToThisBase = true; - break; + if (CXXMethodDecl *MD = + dyn_cast(*Paths.ScratchPath.Decls.first)) { + OverloadedFunctionDecl::function_iterator MatchedDecl; + if (MD->isVirtual() && + !IsOverload(Criteria.Method, MD, MatchedDecl)) { + FoundPathToThisBase = true; + break; + } } ++Paths.ScratchPath.Decls.first; diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp index cf7322156f..dc764da532 100644 --- a/test/SemaCXX/abstract.cpp +++ b/test/SemaCXX/abstract.cpp @@ -118,3 +118,11 @@ void foo(void) B b; } +struct K { + int f; + virtual ~K(); +}; + +struct L : public K { + void f(); +}; -- 2.40.0