]> granicus.if.org Git - clang/commitdiff
Expand the argument diagnostics for too many arguments and give
authorEric Christopher <echristo@apple.com>
Fri, 16 Apr 2010 04:56:46 +0000 (04:56 +0000)
committerEric Christopher <echristo@apple.com>
Fri, 16 Apr 2010 04:56:46 +0000 (04:56 +0000)
both number seen and number expected.

Finishes fixing PR6501.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101442 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaChecking.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprObjC.cpp

index aa968953833d53f0b7c018e1d7f9096a6a0cce7a..6f430ff7d3664074885631ba896402d9e90d4e5f 100644 (file)
@@ -2366,7 +2366,11 @@ def err_typecheck_call_too_few_args_at_least : Error<
   "too few arguments to %select{function|block|method}0 call, "
   "expected at least %1, have %2">;
 def err_typecheck_call_too_many_args : Error<
-  "too many arguments to %select{function|block|method}0 call">;
+  "too many arguments to %select{function|block|method}0 call, "
+  "expected %1, have %2">;
+def err_typecheck_call_too_many_args_at_most : Error<
+  "too many arguments to %select{function|block|method}0 call, "
+  "expected at most %1, have %2">;
 def warn_call_wrong_number_of_arguments : Warning<
   "too %select{few|many}0 arguments in call to %1">;
 def err_atomic_builtin_must_be_pointer : Error<
index 4e33cc67e221442f0792fe43b6c8d2ddc29e392e..64e0e264afe07ff675d349d92ddd6807b7fd6c53 100644 (file)
@@ -480,7 +480,8 @@ bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) {
   if (TheCall->getNumArgs() > 2) {
     Diag(TheCall->getArg(2)->getLocStart(),
          diag::err_typecheck_call_too_many_args)
-      << 0 /*function call*/ << Fn->getSourceRange()
+      << 0 /*function call*/ << 2 << TheCall->getNumArgs()
+      << Fn->getSourceRange()
       << SourceRange(TheCall->getArg(2)->getLocStart(),
                      (*(TheCall->arg_end()-1))->getLocEnd());
     return true;
@@ -547,7 +548,7 @@ bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
   if (TheCall->getNumArgs() > 2)
     return Diag(TheCall->getArg(2)->getLocStart(),
                 diag::err_typecheck_call_too_many_args)
-      << 0 /*function call*/
+      << 0 /*function call*/ << 2 << TheCall->getNumArgs()
       << SourceRange(TheCall->getArg(2)->getLocStart(),
                      (*(TheCall->arg_end()-1))->getLocEnd());
 
@@ -589,7 +590,7 @@ bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) {
   if (TheCall->getNumArgs() > NumArgs)
     return Diag(TheCall->getArg(NumArgs)->getLocStart(),
                 diag::err_typecheck_call_too_many_args)
-      << 0 /*function call*/
+      << 0 /*function call*/ << NumArgs << TheCall->getNumArgs()
       << SourceRange(TheCall->getArg(NumArgs)->getLocStart(),
                      (*(TheCall->arg_end()-1))->getLocEnd());
 
@@ -658,7 +659,9 @@ Action::OwningExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
                  << TheCall->getSourceRange());
       return ExprError(Diag(TheCall->getLocEnd(),
                             diag::err_typecheck_call_too_many_args)
-                 << 0 /*function call*/ << TheCall->getSourceRange());
+                 << 0 /*function call*/ 
+                 << numElements+2 << TheCall->getNumArgs()
+                 << TheCall->getSourceRange());
     }
   }
 
@@ -699,8 +702,10 @@ bool Sema::SemaBuiltinPrefetch(CallExpr *TheCall) {
   unsigned NumArgs = TheCall->getNumArgs();
 
   if (NumArgs > 3)
-    return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args)
-             << 0 /*function call*/ << TheCall->getSourceRange();
+    return Diag(TheCall->getLocEnd(),
+             diag::err_typecheck_call_too_many_args_at_most)
+             << 0 /*function call*/ << 3 << NumArgs
+             << TheCall->getSourceRange();
 
   // Argument 0 is checked for us and the remaining arguments must be
   // constant integers.
index 4fec07930ddc51f38e521a02f4efd82cdfa74e01..d42129c4893e344ddc73e9b6797af05d8f29772f 100644 (file)
@@ -3346,7 +3346,8 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
     if (!Proto->isVariadic()) {
       Diag(Args[NumArgsInProto]->getLocStart(),
            diag::err_typecheck_call_too_many_args)
-        << Fn->getType()->isBlockPointerType() << Fn->getSourceRange()
+        << Fn->getType()->isBlockPointerType() 
+        << NumArgsInProto << NumArgs << Fn->getSourceRange()
         << SourceRange(Args[NumArgsInProto]->getLocStart(),
                        Args[NumArgs-1]->getLocEnd());
       // This deletes the extra arguments.
index cc44e30295726cec64195dac8c50e7b178616d98..c0e04fd6d40c8caae413bf47335b48d19d9d4677 100644 (file)
@@ -228,7 +228,8 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
     if (NumArgs != NumNamedArgs) {
       Diag(Args[NumNamedArgs]->getLocStart(),
            diag::err_typecheck_call_too_many_args)
-        << 2 /*method*/ << Method->getSourceRange()
+        << 2 /*method*/ << NumNamedArgs << NumArgs
+        << Method->getSourceRange()
         << SourceRange(Args[NumNamedArgs]->getLocStart(),
                        Args[NumArgs-1]->getLocEnd());
     }