forked from OSchip/llvm-project
Fix off-by-one error when emitting diagnostics. Also, make diagnostic
a bit nicer for people who pass lots of extra arguments to calls by selecting them all instead of just the first one: arg-duplicate.c:13:13: error: too many arguments to function f3 (1, 1, 2, 3, 4); // expected-error {{too many arguments to function}} ^~~~~~~ This implements test/Sema/arg-duplicate.c, thanks to Neil for pointing out this crash. llvm-svn: 40136
This commit is contained in:
parent
38dbdb2c9c
commit
a6f5ab5425
|
@ -409,9 +409,10 @@ ParseCallExpr(ExprTy *fn, SourceLocation LParenLoc,
|
||||||
Fn->getSourceRange());
|
Fn->getSourceRange());
|
||||||
else if (NumArgsInCall > NumArgsInProto) {
|
else if (NumArgsInCall > NumArgsInProto) {
|
||||||
if (!proto->isVariadic()) {
|
if (!proto->isVariadic()) {
|
||||||
Diag(Args[NumArgsInProto+1]->getLocStart(),
|
Diag(Args[NumArgsInProto]->getLocStart(),
|
||||||
diag::err_typecheck_call_too_many_args, Fn->getSourceRange(),
|
diag::err_typecheck_call_too_many_args, Fn->getSourceRange(),
|
||||||
Args[NumArgsInProto+1]->getSourceRange());
|
SourceRange(Args[NumArgsInProto]->getLocStart(),
|
||||||
|
Args[NumArgsInCall-1]->getLocEnd()));
|
||||||
}
|
}
|
||||||
NumArgsToCheck = NumArgsInProto;
|
NumArgsToCheck = NumArgsInProto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
// RUN: clang -parse-ast-check %s
|
||||||
|
|
||||||
|
typedef int x;
|
||||||
|
int f3(y, x,
|
||||||
|
x) // expected-error {{redefinition of parameter}}
|
||||||
|
int y, x,
|
||||||
|
x; // expected-error {{redefinition of parameter}}
|
||||||
|
{
|
||||||
|
return x + y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void f4(void) {
|
||||||
|
f3 (1, 1, 2, 3, 4); // expected-error {{too many arguments to function}}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue