CXXMethodDecl::isVirtual needs to check the canonical declaration. Fixes PR4878.

llvm-svn: 81715
This commit is contained in:
Anders Carlsson 2009-09-13 21:01:57 +00:00
parent eb2cc68254
commit 002f2b3eec
2 changed files with 17 additions and 2 deletions

View File

@ -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());
}
///

View File

@ -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();
}