I broke out the "no viable candidates" case in build_new_method_call_1 into a subroutine, and added special-case handling for when there's a single non-viable candidate where there's an argument conversion error. I turned the error-handling from convert_for_assignment into a subroutine, calling it from this new special-case. This converts: demo.cc: In function 'int test_4(int, const char*, float)': demo.cc:5:44: error: no matching function for call to 's4::member_1(int&, const char*&, float&)' 5 | return s4::member_1 (first, second, third); | ^ demo.cc:1:24: note: candidate: 'static int s4::member_1(int, const char**, float)' 1 | struct s4 { static int member_1 (int one, const char **two, float three); }; | ^~~~~~~~ demo.cc:1:56: note: no known conversion for argument 2 from 'const char*' to 'const char**' 1 | struct s4 { static int member_1 (int one, const char **two, float three); }; | ~~~~~~~~~~~~~^~~ to: demo.cc: In function 'int test_4(int, const char*, float)': demo.cc:5:31: error: cannot convert 'const char*' to 'const char**' 5 | return s4::member_1 (first, second, third); | ^~~~~~ | | | const char* demo.cc:1:56: note: initializing argument 2 of 'static int s4::member_1(int, const char**, float)' 1 | struct s4 { static int member_1 (int one, const char **two, float three); }; | ~~~~~~~~~~~~~^~~ thus highlighting the problematic argument at the callsite (and its type). gcc/cp/ChangeLog: PR c++/85110 * call.c (struct conversion_info): Add "loc" field. (arg_conversion_rejection): Add "loc" param, using it to initialize the new field. (bad_arg_conversion_rejection): Likewise. (explicit_conversion_rejection): Initialize the new field to UNKNOWN_LOCATION. (template_conversion_rejection): Likewise. (add_function_candidate): Pass on the argument location to the new param of arg_conversion_rejection. (add_conv_candidate): Likewise. (build_builtin_candidate): Likewise. (build_user_type_conversion_1): Likewise. (single_z_candidate): New function. (maybe_get_bad_conversion_for_unmatched_call): New function. (complain_about_bad_argument): New function, based on part of convert_for_assignment. (build_new_method_call_1): Split out handling of the "no viable candidates" case into... (complain_about_no_candidates_for_method_call): ...this new function, and use the new functions above to special-case the handling of a single non-viable candidate due to a bad argument. * cp-tree.h (complain_about_bad_argument): New decl. * typeck.c (convert_for_assignment): Split out one error-handling case into complain_about_bad_argument. gcc/testsuite/ChangeLog: PR c++/85110 * g++.dg/cpp0x/explicit4.C: Update expected output to reflect special-casing of diagnostic for a single non-viable candidate due to a bad argument. * g++.dg/diagnostic/param-type-mismatch-2.C: Likewise. Add test coverage for an unmatched overloaded operator. * g++.dg/expr/pmf-1.C: Likewise. * g++.old-deja/g++.bugs/900330_02.C: Likewise. * g++.old-deja/g++.jason/conversion11.C: Likewise. * g++.old-deja/g++.law/arg11.C: Likewise. * g++.old-deja/g++.law/arm9.C: Likewise. * g++.old-deja/g++.robertl/eb131.C: Likewise. From-SVN: r264250
Name |
Last commit
|
Last update |
---|---|---|
INSTALL | Loading commit data... | |
config | Loading commit data... | |
contrib | Loading commit data... | |
fixincludes | Loading commit data... | |
gcc | Loading commit data... | |
gnattools | Loading commit data... | |
gotools | Loading commit data... | |
include | Loading commit data... | |
intl | Loading commit data... | |
libada | Loading commit data... | |
libatomic | Loading commit data... | |
libbacktrace | Loading commit data... | |
libcc1 | Loading commit data... | |
libcpp | Loading commit data... | |
libdecnumber | Loading commit data... | |
libffi | Loading commit data... | |
libgcc | Loading commit data... | |
libgfortran | Loading commit data... | |
libgo | Loading commit data... | |
libgomp | Loading commit data... | |
libhsail-rt | Loading commit data... | |
libiberty | Loading commit data... | |
libitm | Loading commit data... | |
libobjc | Loading commit data... | |
liboffloadmic | Loading commit data... | |
libquadmath | Loading commit data... | |
libsanitizer | Loading commit data... | |
libssp | Loading commit data... | |
libstdc++-v3 | Loading commit data... | |
libvtv | Loading commit data... | |
lto-plugin | Loading commit data... | |
maintainer-scripts | Loading commit data... | |
zlib | Loading commit data... | |
.dir-locals.el | Loading commit data... | |
.gitattributes | Loading commit data... | |
.gitignore | Loading commit data... | |
ABOUT-NLS | Loading commit data... | |
COPYING | Loading commit data... | |
COPYING.LIB | Loading commit data... | |
COPYING.RUNTIME | Loading commit data... | |
COPYING3 | Loading commit data... | |
COPYING3.LIB | Loading commit data... | |
ChangeLog | Loading commit data... | |
ChangeLog.jit | Loading commit data... | |
ChangeLog.tree-ssa | Loading commit data... | |
MAINTAINERS | Loading commit data... | |
Makefile.def | Loading commit data... | |
Makefile.in | Loading commit data... | |
Makefile.tpl | Loading commit data... | |
README | Loading commit data... | |
compile | Loading commit data... | |
config-ml.in | Loading commit data... | |
config.guess | Loading commit data... | |
config.rpath | Loading commit data... | |
config.sub | Loading commit data... | |
configure | Loading commit data... | |
configure.ac | Loading commit data... | |
depcomp | Loading commit data... | |
install-sh | Loading commit data... | |
libtool-ldflags | Loading commit data... | |
libtool.m4 | Loading commit data... | |
ltgcc.m4 | Loading commit data... | |
ltmain.sh | Loading commit data... | |
ltoptions.m4 | Loading commit data... | |
ltsugar.m4 | Loading commit data... | |
ltversion.m4 | Loading commit data... | |
lt~obsolete.m4 | Loading commit data... | |
missing | Loading commit data... | |
mkdep | Loading commit data... | |
mkinstalldirs | Loading commit data... | |
move-if-change | Loading commit data... | |
symlink-tree | Loading commit data... | |
ylwrap | Loading commit data... |