pr88375.cc:12:1: error: cannot convert 'a' to 'int' in initialization
12 | };
| ^
with the error at the final closing brace.
This patch uses location information for the initializers, converting the
above to:
pr88375.cc:10:11: error: cannot convert 'a' to 'int' in initialization
10 | { 3, a::two },
| ~~~^~~
| |
| a
highlighting which subexpression is problematic, and its type.
Ideally we'd also issue a note showing the field decl being initialized,
but that turned out to be more invasive.
gcc/cp/ChangeLog:
PR c++/88375
* typeck.c (convert_for_assignment): Capture location of rhs
before stripping, and if available. Use the location when
complaining about bad conversions, labelling it with the
rhstype if the location was present.
* typeck2.c (digest_init_r): Capture location of init before
stripping.
gcc/testsuite/ChangeLog:
PR c++/88375
* g++.dg/init/pr88375-2.C: New test.
* g++.dg/init/pr88375.C: New test.