aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-05-11 05:16:41 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-05-11 05:16:41 +0000
commitf7b8056f1ff0c0409a9523a34f78b69ab8314bec (patch)
tree1fb0849590b2e2429b9a560b9df7cc19698282da /lib/Sema/SemaExpr.cpp
parent79993dc53d212c663415d3c48ed5ec41cee2bdf7 (diff)
PR11857: When the wrong number of arguments are provided for a function
which expects exactly one argument, include the name of the argument in the diagnostic text. Patch by Terry Long! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 3ab0723ab0..0f9793d839 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3380,11 +3380,18 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
// arguments for the remaining parameters), don't make the call.
if (NumArgs < NumArgsInProto) {
if (NumArgs < MinArgs) {
- Diag(RParenLoc, MinArgs == NumArgsInProto
- ? diag::err_typecheck_call_too_few_args
- : diag::err_typecheck_call_too_few_args_at_least)
- << FnKind
- << MinArgs << NumArgs << Fn->getSourceRange();
+ if (MinArgs == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName())
+ Diag(RParenLoc, MinArgs == NumArgsInProto && !Proto->isVariadic()
+ ? diag::err_typecheck_call_too_few_args_one
+ : diag::err_typecheck_call_too_few_args_at_least_one)
+ << FnKind
+ << FDecl->getParamDecl(0) << Fn->getSourceRange();
+ else
+ Diag(RParenLoc, MinArgs == NumArgsInProto && !Proto->isVariadic()
+ ? diag::err_typecheck_call_too_few_args
+ : diag::err_typecheck_call_too_few_args_at_least)
+ << FnKind
+ << MinArgs << NumArgs << Fn->getSourceRange();
// Emit the location of the prototype.
if (FDecl && !FDecl->getBuiltinID() && !IsExecConfig)