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 | 726d11c41b99e7e2b54547dfade6d327adaac79f (patch) | |
| tree | 815e79dd98227384720e3c31e5c98184c911b196 /clang/lib | |
| parent | 60a25a571ee0cddeb02e8ec5e373398aff0d6a8f (diff) | |
| download | bcm5719-llvm-726d11c41b99e7e2b54547dfade6d327adaac79f.tar.gz bcm5719-llvm-726d11c41b99e7e2b54547dfade6d327adaac79f.zip | |
Make sure we perform the variadic method check correctly for calls to a member operator(). PR14057.
llvm-svn: 165678
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 81be8bfe8f3..63c7bdd0cb3 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/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); |

