aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-13 21:01:57 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-13 21:01:57 +0000
commit8195bc932d27e21be46b9a1f8ce268ebd419246b (patch)
tree3bd6deedd5b72e169b73ee20e59f309c087cb3d3
parente0c8822eec9d3b2afa62c5e6168a8a8f52aeb2c4 (diff)
CXXMethodDecl::isVirtual needs to check the canonical declaration. Fixes PR4878.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81715 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclCXX.h9
-rw-r--r--test/SemaCXX/attr-deprecated.cpp10
2 files changed, 17 insertions, 2 deletions
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 7fdb820ae3..4d7c674835 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -776,8 +776,13 @@ public:
bool isInstance() const { return !isStatic(); }
bool isVirtual() const {
- return isVirtualAsWritten() ||
- (begin_overridden_methods() != end_overridden_methods());
+ CXXMethodDecl *CD =
+ cast<CXXMethodDecl>(const_cast<CXXMethodDecl*>(this)->getCanonicalDecl());
+
+ if (CD->isVirtualAsWritten())
+ return true;
+
+ return (CD->begin_overridden_methods() != CD->end_overridden_methods());
}
///
diff --git a/test/SemaCXX/attr-deprecated.cpp b/test/SemaCXX/attr-deprecated.cpp
index c1bdfcca97..54f8b5b57f 100644
--- a/test/SemaCXX/attr-deprecated.cpp
+++ b/test/SemaCXX/attr-deprecated.cpp
@@ -54,3 +54,13 @@ void f(B* b, C *c) {
c->C::f();
c->B::f(); // expected-warning{{'f' is deprecated}}
}
+
+struct D {
+ virtual void f() __attribute__((deprecated));
+};
+
+void D::f() { }
+
+void f(D* d) {
+ d->f();
+}