This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] C++: highlight bad argument in some users of print_z_candidates (more PR c++/85110)


On Thu, Aug 23, 2018 at 2:08 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> This is a followup to:
>
>   "[PATCH] C++: underline param in print_conversion_rejection (more PR c++/85110)"
>      https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01480.html
>
> to highlight the pertinent argument in a unmatched function call
> for which there is one candidate.
>
> It updates the output from:
>
> 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: no matching function for call to 's4::member_1(int&, const char*&, float&)'
> 5 |   return s4::member_1 (first, second, third);
>   |                               ^~~~~~

Hmm, it seems pretty subtle to just change the highlighting when the
message talks about the call as a whole.  I think if we're going to
focus in this way we might change the diagnostic to something like

error: no known conversion for argument 2 from 'const char*' to 'const char**'
note: in call to 'static int s4::member_1(int, const char**, float)'

or whatever the messages are from
convert_arguments/convert_for_initialization which already deal with
the single-candidate case for non-member functions.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]