aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-10-02 23:49:20 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2011-10-02 23:49:20 +0000
commitaf15b4d0aa2da714ff1648ddf6db17154d9a7f26 (patch)
treea250143025182159d6820b2ff743829aade28d05 /lib/Sema/SemaExpr.cpp
parent8591a7f5215f6469603e6bc8f4fdbcc78e215ab9 (diff)
Add ConvertArgumentsForCall diagnostics for at least/at most n args
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140976 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index eb5678e7f0..0d4c7bea17 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3271,14 +3271,17 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
// assignment, to the types of the corresponding parameter, ...
unsigned NumArgsInProto = Proto->getNumArgs();
bool Invalid = false;
+ unsigned MinArgs = FDecl ? FDecl->getMinRequiredArguments() : NumArgsInProto;
// If too few arguments are available (and we don't have default
// arguments for the remaining parameters), don't make the call.
if (NumArgs < NumArgsInProto) {
- if (!FDecl || NumArgs < FDecl->getMinRequiredArguments()) {
- Diag(RParenLoc, diag::err_typecheck_call_too_few_args)
+ if (NumArgs < MinArgs) {
+ Diag(RParenLoc, MinArgs == NumArgsInProto
+ ? diag::err_typecheck_call_too_few_args
+ : diag::err_typecheck_call_too_few_args_at_least)
<< Fn->getType()->isBlockPointerType()
- << NumArgsInProto << NumArgs << Fn->getSourceRange();
+ << MinArgs << NumArgs << Fn->getSourceRange();
// Emit the location of the prototype.
if (FDecl && !FDecl->getBuiltinID())
@@ -3295,7 +3298,9 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
if (NumArgs > NumArgsInProto) {
if (!Proto->isVariadic()) {
Diag(Args[NumArgsInProto]->getLocStart(),
- diag::err_typecheck_call_too_many_args)
+ MinArgs == NumArgsInProto
+ ? diag::err_typecheck_call_too_many_args
+ : diag::err_typecheck_call_too_many_args_at_most)
<< Fn->getType()->isBlockPointerType()
<< NumArgsInProto << NumArgs << Fn->getSourceRange()
<< SourceRange(Args[NumArgsInProto]->getLocStart(),