mirror of
https://github.com/intel/llvm.git
synced 2026-01-31 07:27:33 +08:00
merge some simple call diagnostics.
llvm-svn: 59831
This commit is contained in:
@@ -1252,13 +1252,9 @@ DIAG(err_block_decl_ref_not_modifiable_lvalue, ERROR,
|
||||
DIAG(err_typecheck_call_not_function, ERROR,
|
||||
"called object type '%0' is not a function or function pointer")
|
||||
DIAG(err_typecheck_call_too_few_args, ERROR,
|
||||
"too few arguments to function")
|
||||
DIAG(err_typecheck_block_too_few_args, ERROR,
|
||||
"too few arguments to block")
|
||||
"too few arguments to %select{function|block|method}0 call")
|
||||
DIAG(err_typecheck_call_too_many_args, ERROR,
|
||||
"too many arguments to function")
|
||||
DIAG(err_typecheck_block_too_many_args, ERROR,
|
||||
"too many arguments to block call")
|
||||
"too many arguments to %select{function|block|method}0 call")
|
||||
DIAG(err_typecheck_closure_too_many_args, ERROR,
|
||||
"too many arguments to closure call")
|
||||
DIAG(err_typecheck_call_invalid_ordered_compare, ERROR,
|
||||
|
||||
@@ -153,9 +153,9 @@ bool Sema::CheckBuiltinCFStringArgument(Expr* Arg) {
|
||||
bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) {
|
||||
Expr *Fn = TheCall->getCallee();
|
||||
if (TheCall->getNumArgs() > 2) {
|
||||
Diag(TheCall->getArg(2)->getLocStart(),
|
||||
Diag(TheCall->getArg(2)->getLocStart(),
|
||||
diag::err_typecheck_call_too_many_args)
|
||||
<< Fn->getSourceRange()
|
||||
<< 0 /*function call*/ << Fn->getSourceRange()
|
||||
<< SourceRange(TheCall->getArg(2)->getLocStart(),
|
||||
(*(TheCall->arg_end()-1))->getLocEnd());
|
||||
return true;
|
||||
@@ -202,10 +202,12 @@ bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) {
|
||||
/// friends. This is declared to take (...), so we have to check everything.
|
||||
bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
|
||||
if (TheCall->getNumArgs() < 2)
|
||||
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args);
|
||||
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
|
||||
<< 0 /*function call*/;
|
||||
if (TheCall->getNumArgs() > 2)
|
||||
return Diag(TheCall->getArg(2)->getLocStart(),
|
||||
diag::err_typecheck_call_too_many_args)
|
||||
<< 0 /*function call*/
|
||||
<< SourceRange(TheCall->getArg(2)->getLocStart(),
|
||||
(*(TheCall->arg_end()-1))->getLocEnd());
|
||||
|
||||
@@ -242,7 +244,7 @@ bool Sema::SemaBuiltinStackAddress(CallExpr *TheCall) {
|
||||
Action::ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
|
||||
if (TheCall->getNumArgs() < 3)
|
||||
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
|
||||
<< TheCall->getSourceRange();
|
||||
<< 0 /*function call*/ << TheCall->getSourceRange();
|
||||
|
||||
QualType FAType = TheCall->getArg(0)->getType();
|
||||
QualType SAType = TheCall->getArg(1)->getType();
|
||||
@@ -266,9 +268,9 @@ Action::ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
|
||||
if (TheCall->getNumArgs() != numElements+2) {
|
||||
if (TheCall->getNumArgs() < numElements+2)
|
||||
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
|
||||
<< TheCall->getSourceRange();
|
||||
<< 0 /*function call*/ << TheCall->getSourceRange();
|
||||
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args)
|
||||
<< TheCall->getSourceRange();
|
||||
<< 0 /*function call*/ << TheCall->getSourceRange();
|
||||
}
|
||||
|
||||
for (unsigned i = 2; i < TheCall->getNumArgs(); i++) {
|
||||
@@ -304,7 +306,7 @@ bool Sema::SemaBuiltinPrefetch(CallExpr *TheCall) {
|
||||
|
||||
if (NumArgs > 3)
|
||||
return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args)
|
||||
<< TheCall->getSourceRange();
|
||||
<< 0 /*function call*/ << TheCall->getSourceRange();
|
||||
|
||||
// Argument 0 is checked for us and the remaining arguments must be
|
||||
// constant integers.
|
||||
|
||||
@@ -1369,27 +1369,21 @@ ActOnCallExpr(ExprTy *fn, SourceLocation LParenLoc,
|
||||
// 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()) {
|
||||
// Use default arguments for missing arguments
|
||||
NumArgsToCheck = NumArgsInProto;
|
||||
TheCall->setNumArgs(NumArgsInProto);
|
||||
} else
|
||||
return Diag(RParenLoc,
|
||||
!Fn->getType()->isBlockPointerType()
|
||||
? diag::err_typecheck_call_too_few_args
|
||||
: diag::err_typecheck_block_too_few_args)
|
||||
<< Fn->getSourceRange();
|
||||
if (!FDecl || NumArgs < FDecl->getMinRequiredArguments())
|
||||
return Diag(RParenLoc, diag::err_typecheck_call_too_few_args)
|
||||
<< Fn->getType()->isBlockPointerType() << Fn->getSourceRange();
|
||||
// Use default arguments for missing arguments
|
||||
NumArgsToCheck = NumArgsInProto;
|
||||
TheCall->setNumArgs(NumArgsInProto);
|
||||
}
|
||||
|
||||
// If too many are passed and not variadic, error on the extras and drop
|
||||
// them.
|
||||
if (NumArgs > NumArgsInProto) {
|
||||
if (!Proto->isVariadic()) {
|
||||
Diag(Args[NumArgsInProto]->getLocStart(),
|
||||
!Fn->getType()->isBlockPointerType()
|
||||
? diag::err_typecheck_call_too_many_args
|
||||
: diag::err_typecheck_block_too_many_args)
|
||||
<< Fn->getSourceRange()
|
||||
Diag(Args[NumArgsInProto]->getLocStart(),
|
||||
diag::err_typecheck_call_too_many_args)
|
||||
<< Fn->getType()->isBlockPointerType() << Fn->getSourceRange()
|
||||
<< SourceRange(Args[NumArgsInProto]->getLocStart(),
|
||||
Args[NumArgs-1]->getLocEnd());
|
||||
// This deletes the extra arguments.
|
||||
|
||||
@@ -161,7 +161,7 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs,
|
||||
if (NumArgs != NumNamedArgs) {
|
||||
Diag(Args[NumNamedArgs]->getLocStart(),
|
||||
diag::err_typecheck_call_too_many_args)
|
||||
<< Method->getSourceRange()
|
||||
<< 2 /*method*/ << Method->getSourceRange()
|
||||
<< SourceRange(Args[NumNamedArgs]->getLocStart(),
|
||||
Args[NumArgs-1]->getLocEnd());
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ void cfstring() {
|
||||
CFSTR("\242"); // expected-warning {{ CFString literal contains non-ASCII character }}
|
||||
CFSTR("\0"); // expected-warning {{ CFString literal contains NUL character }}
|
||||
CFSTR(242); // expected-error {{ CFString literal is not a string constant }} expected-warning {{incompatible integer to pointer conversion}}
|
||||
CFSTR("foo", "bar"); // expected-error {{ error: too many arguments to function }}
|
||||
CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -66,5 +66,5 @@ extern Class NSClassFromObject(id object);
|
||||
@end
|
||||
|
||||
int f0(I0 *ob) {
|
||||
[ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to function}}
|
||||
[ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user