More underlining of bad arguments (PR c++/85110)
As of r256448, the C++ frontend underlines many bad arguments in its
diagnostics; those where perform_overload_resolution returns a
non-NULL candidate, but there's a failure in convert_like_real.
However, for the case where perform_overload_resolution fails, but
there's a single non-viable candidate, the error is diagnosed by
cp_build_function_call_vec, and that currently doesn't underline
the bad argument:
$ cat test.cc
void callee (int one, const char **two, int three);
void
caller (const char *fmt)
{
callee (1, fmt, 3);
}
We emit:
$ g++ test.cc
test.cc: In function 'void caller(const char*)':
test.cc:6:20: error: cannot convert 'const char*' to 'const char**' for argument '2' to 'void callee(int, const char**, int)'
callee (1, fmt, 3);
^
It's going through convert_for_assignment, and
implicitly using input_location.
This patch updates convert_for_assignment for this case, using
an EXPR_LOCATION if there is one, or falling back to input_location
otherwise, underlining the argument in question:
test.cc: In function 'void caller(const char*)':
test.cc:6:14: error: cannot convert 'const char*' to 'const char**' for argument '2' to 'void callee(int, const char**, int)'
callee (1, fmt, 3);
^~~
gcc/cp/ChangeLog:
PR c++/85110
* typeck.c (convert_for_assignment): When complaining due to
conversions for an argument, attempt to use the location of the
argument.
gcc/testsuite/ChangeLog:
PR c++/85110
* g++.dg/diagnostic/param-type-mismatch-2.C: New test.
From-SVN: r258957