diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-10-11 00:30:58 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-10-11 00:30:58 +0000 |
commit | 2edcde8747a000113b434a5c88b4648beed4197b (patch) | |
tree | 2fbae6557f3eb97ff58b88bc4e27e09ceb4a9dd8 /lib/Sema/SemaChecking.cpp | |
parent | 786e6204e55cc01094a3e86104c82932a65fb2ca (diff) |
Make sure we perform the variadic method check correctly for calls to a member operator(). PR14057.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 81be8bfe8f..63c7bdd0cb 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -542,11 +542,23 @@ void Sema::CheckConstructorCall(FunctionDecl *FDecl, Expr **Args, /// and safety properties not strictly enforced by the C type system. bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto) { - bool IsMemberFunction = isa<CXXMemberCallExpr>(TheCall); + bool IsMemberOperatorCall = isa<CXXOperatorCallExpr>(TheCall) && + isa<CXXMethodDecl>(FDecl); + bool IsMemberFunction = isa<CXXMemberCallExpr>(TheCall) || + IsMemberOperatorCall; VariadicCallType CallType = getVariadicCallType(FDecl, Proto, TheCall->getCallee()); unsigned NumProtoArgs = Proto ? Proto->getNumArgs() : 0; - checkCall(FDecl, TheCall->getArgs(), TheCall->getNumArgs(), NumProtoArgs, + Expr** Args = TheCall->getArgs(); + unsigned NumArgs = TheCall->getNumArgs(); + if (isa<CXXOperatorCallExpr>(TheCall) && isa<CXXMethodDecl>(FDecl)) { + // If this is a call to a member operator, hide the first argument + // from checkCall. + // FIXME: Our choice of AST representation here is less than ideal. + ++Args; + --NumArgs; + } + checkCall(FDecl, Args, NumArgs, NumProtoArgs, IsMemberFunction, TheCall->getRParenLoc(), TheCall->getCallee()->getSourceRange(), CallType); |