Apply the typo correction replacement location fix from r191450 to the
case when correcting for too many arguments (r191450 had only fixed the problem for when there were too few arguments). Also fix the underlining for both cases. llvm-svn: 200268
This commit is contained in:
parent
c809cbcf4d
commit
59baee8451
|
@ -4047,7 +4047,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
: diag::err_typecheck_call_too_few_args_at_least_suggest;
|
||||
diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
|
||||
<< static_cast<unsigned>(Args.size())
|
||||
<< Fn->getSourceRange());
|
||||
<< TC.getCorrectionRange());
|
||||
} else if (MinArgs == 1 && FDecl && FDecl->getParamDecl(0)->getDeclName())
|
||||
Diag(RParenLoc,
|
||||
MinArgs == NumParams && !Proto->isVariadic()
|
||||
|
@ -4075,10 +4075,12 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
// them.
|
||||
if (Args.size() > NumParams) {
|
||||
if (!Proto->isVariadic()) {
|
||||
MemberExpr *ME = dyn_cast<MemberExpr>(Fn);
|
||||
TypoCorrection TC;
|
||||
if (FDecl && (TC = TryTypoCorrectionForCall(
|
||||
*this, DeclarationNameInfo(FDecl->getDeclName(),
|
||||
Fn->getLocStart()),
|
||||
(ME ? ME->getMemberLoc()
|
||||
: Fn->getLocStart())),
|
||||
Args))) {
|
||||
unsigned diag_id =
|
||||
MinArgs == NumParams && !Proto->isVariadic()
|
||||
|
@ -4086,7 +4088,7 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
|||
: diag::err_typecheck_call_too_many_args_at_most_suggest;
|
||||
diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
|
||||
<< static_cast<unsigned>(Args.size())
|
||||
<< Fn->getSourceRange());
|
||||
<< TC.getCorrectionRange());
|
||||
} else if (NumParams == 1 && FDecl &&
|
||||
FDecl->getParamDecl(0)->getDeclName())
|
||||
Diag(Args[NumParams]->getLocStart(),
|
||||
|
|
|
@ -19,3 +19,18 @@ void m() {
|
|||
pb->f(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean 'A::f'?}}
|
||||
}
|
||||
}
|
||||
|
||||
namespace PR18608 {
|
||||
struct A {
|
||||
virtual void f() const;
|
||||
virtual void f(int x) const; // expected-note{{'A::f' declared here}}
|
||||
};
|
||||
|
||||
struct B : public A {
|
||||
virtual void f() const;
|
||||
};
|
||||
|
||||
void test(B b) {
|
||||
b.f(1); // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'A::f'?}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue