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
diff --git a/lib/Sema/SemaInherit.cpp b/lib/Sema/SemaInherit.cpp
index 1eccc1f..1b968f0 100644
--- a/lib/Sema/SemaInherit.cpp
+++ b/lib/Sema/SemaInherit.cpp
@@ -195,13 +195,14 @@
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;
diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp
index cf73221..dc764da 100644
--- a/test/SemaCXX/abstract.cpp
+++ b/test/SemaCXX/abstract.cpp
@@ -118,3 +118,11 @@
B b;
}
+struct K {
+ int f;
+ virtual ~K();
+};
+
+struct L : public K {
+ void f();
+};