aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-10 20:48:14 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-10 20:48:14 +0000
commit0f728566b9fc1a013be3c0f3ca43a074307dc081 (patch)
tree7d7e0e15f1e28bb8430da4d4cbd3269871ca254f /lib
parent59600d80b7e34e819cd25dd67f661aa1f3d9099d (diff)
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81460 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaExpr.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 723d6d7dfa..53f3dde283 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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)) {