mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 12:26:52 +08:00
Don't check use of a member function declaration used if the member function is virtual and the member reference expression doesn't explicitly qualify it. Fixes PR4878.
llvm-svn: 81460
This commit is contained in:
@@ -2142,8 +2142,16 @@ Sema::BuildMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
|
||||
if (MemberDecl->isInvalidDecl())
|
||||
return ExprError();
|
||||
|
||||
bool ShouldCheckUse = true;
|
||||
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(MemberDecl)) {
|
||||
// Don't diagnose the use of a virtual member function unless it's
|
||||
// explicitly qualified.
|
||||
if (MD->isVirtual() && (!SS || !SS->isSet()))
|
||||
ShouldCheckUse = false;
|
||||
}
|
||||
|
||||
// Check the use of this field
|
||||
if (DiagnoseUseOfDecl(MemberDecl, MemberLoc))
|
||||
if (ShouldCheckUse && DiagnoseUseOfDecl(MemberDecl, MemberLoc))
|
||||
return ExprError();
|
||||
|
||||
if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) {
|
||||
|
||||
@@ -24,3 +24,20 @@ void A::h(A* a)
|
||||
(void)b;
|
||||
(void)a->b;
|
||||
}
|
||||
|
||||
struct B {
|
||||
virtual void f() __attribute__((deprecated));
|
||||
};
|
||||
|
||||
struct C : B {
|
||||
virtual void f();
|
||||
};
|
||||
|
||||
void f(B* b, C *c) {
|
||||
b->f();
|
||||
b->B::f(); // expected-warning{{'f' is deprecated}}
|
||||
|
||||
c->f();
|
||||
c->C::f();
|
||||
c->B::f(); // expected-warning{{'f' is deprecated}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user