diff options
author | Eric Christopher <echristo@apple.com> | 2010-04-16 04:48:22 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-04-16 04:48:22 +0000 |
commit | d77b9a29651d748f0e30a8dad8969635fc04f725 (patch) | |
tree | a9a564f0348c03696a45cc816edbf61ab9af04cf /lib/Sema/SemaChecking.cpp | |
parent | e42e9872f82d8e969593b3143cf9e0fdc294e711 (diff) |
Expand argument diagnostic for too few arguments to give the number
of arguments both seen and expected.
Fixes PR6501.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101441 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 5091daf323..4e33cc67e2 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -270,8 +270,10 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) { // Ensure that we have at least one argument to do type inference from. if (TheCall->getNumArgs() < 1) - return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args) - << 0 << TheCall->getCallee()->getSourceRange(); + return Diag(TheCall->getLocEnd(), + diag::err_typecheck_call_too_few_args_at_least) + << 0 << 1 << TheCall->getNumArgs() + << TheCall->getCallee()->getSourceRange(); // Inspect the first argument of the atomic builtin. This should always be // a pointer type, whose element is an integral scalar or pointer type. @@ -367,8 +369,10 @@ bool Sema::SemaBuiltinAtomicOverloaded(CallExpr *TheCall) { // Now that we know how many fixed arguments we expect, first check that we // have at least that many. if (TheCall->getNumArgs() < 1+NumFixed) - return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args) - << 0 << TheCall->getCallee()->getSourceRange(); + return Diag(TheCall->getLocEnd(), + diag::err_typecheck_call_too_few_args_at_least) + << 0 << 1+NumFixed << TheCall->getNumArgs() + << TheCall->getCallee()->getSourceRange(); // Get the decl for the concrete builtin from this, we can tell what the @@ -483,8 +487,9 @@ bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) { } if (TheCall->getNumArgs() < 2) { - return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args) - << 0 /*function call*/; + return Diag(TheCall->getLocEnd(), + diag::err_typecheck_call_too_few_args_at_least) + << 0 /*function call*/ << 2 << TheCall->getNumArgs(); } // Determine whether the current function is variadic or not. @@ -538,7 +543,7 @@ bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) { bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) { if (TheCall->getNumArgs() < 2) return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args) - << 0 /*function call*/; + << 0 << 2 << TheCall->getNumArgs()/*function call*/; if (TheCall->getNumArgs() > 2) return Diag(TheCall->getArg(2)->getLocStart(), diag::err_typecheck_call_too_many_args) @@ -580,7 +585,7 @@ bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) { bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) { if (TheCall->getNumArgs() < NumArgs) return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args) - << 0 /*function call*/; + << 0 << NumArgs << TheCall->getNumArgs()/*function call*/; if (TheCall->getNumArgs() > NumArgs) return Diag(TheCall->getArg(NumArgs)->getLocStart(), diag::err_typecheck_call_too_many_args) @@ -619,8 +624,9 @@ bool Sema::SemaBuiltinStackAddress(CallExpr *TheCall) { Action::OwningExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { if (TheCall->getNumArgs() < 3) return ExprError(Diag(TheCall->getLocEnd(), - diag::err_typecheck_call_too_few_args) - << 0 /*function call*/ << TheCall->getSourceRange()); + diag::err_typecheck_call_too_few_args_at_least) + << 0 /*function call*/ << 3 << TheCall->getNumArgs() + << TheCall->getSourceRange()); unsigned numElements = std::numeric_limits<unsigned>::max(); if (!TheCall->getArg(0)->isTypeDependent() && @@ -647,7 +653,9 @@ Action::OwningExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { if (TheCall->getNumArgs() < numElements+2) return ExprError(Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args) - << 0 /*function call*/ << TheCall->getSourceRange()); + << 0 /*function call*/ + << numElements+2 << TheCall->getNumArgs() + << TheCall->getSourceRange()); return ExprError(Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args) << 0 /*function call*/ << TheCall->getSourceRange()); |