[Sema] Diagnose use of declaration correctly.

Before we skipped that for virtual functions not fully qualified (r81507).
This commit basically reverts this to the older behaviour, which seems
more consistent. We now also correctly consider ill-formed calls to deleted
member functions, which were silently passed before in some cases.
The review contains the whole discussion.

PR:		20268
Differential Revision:	 http://reviews.llvm.org/D11334

llvm-svn: 242857
This commit is contained in:
Davide Italiano 2015-07-22 00:30:58 +00:00
parent e171da5cb7
commit f179e36e0e
3 changed files with 12 additions and 14 deletions

View File

@ -1042,16 +1042,8 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
BaseExpr = new (Context) CXXThisExpr(Loc, BaseExprType,/*isImplicit=*/true);
}
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.isSet())
ShouldCheckUse = false;
}
// Check the use of this member.
if (ShouldCheckUse && DiagnoseUseOfDecl(MemberDecl, MemberLoc))
if (DiagnoseUseOfDecl(MemberDecl, MemberLoc))
return ExprError();
if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl))

View File

@ -26,12 +26,12 @@ void A::h(A* a)
}
struct B {
virtual void f() __attribute__((deprecated)); // expected-note 4 {{'f' has been explicitly marked deprecated here}}
virtual void f() __attribute__((deprecated)); // expected-note 6 {{'f' has been explicitly marked deprecated here}}
void g();
};
void B::g() {
f();
f(); // expected-warning{{'f' is deprecated}}
B::f(); // expected-warning{{'f' is deprecated}}
}
@ -47,7 +47,7 @@ void C::g() {
}
void f(B* b, C *c) {
b->f();
b->f(); // expected-warning{{'f' is deprecated}}
b->B::f(); // expected-warning{{'f' is deprecated}}
c->f();
@ -59,10 +59,10 @@ struct D {
virtual void f() __attribute__((deprecated));
};
void D::f() { }
void D::f() { } // expected-note{{'f' has been explicitly marked deprecated here}}
void f(D* d) {
d->f();
d->f(); // expected-warning{{'f' is deprecated}}
}

View File

@ -0,0 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
struct S {
virtual void f() = delete; //expected-note{{'f' has been explicitly marked deleted here}}
void g() { f(); } //expected-error{{attempt to use a deleted function}}
};