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: underline parameters in mismatching function calls


> On Oct 2, 2017, at 4:05 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> 
> ...
> the C FE currently emits (trunk):
> 
>  test.c: In function 'caller':
>  test.c:5:25: warning: passing argument 2 of 'callee' makes pointer from
>  integer without a cast [-Wint-conversion]
>     return callee (first, second, third);
>                           ^~~~~~
>  test.c:1:12: note: expected 'const char *' but argument is of type 'int'
>   extern int callee (int one, const char *two, float three);
>              ^~~~~~
> 
> whereas with this patch the note underlines the pertinent param of
> the callee:
> 
>  test.c: In function 'caller':
>  test.c:5:25: warning: passing argument 2 of 'callee' makes pointer from
>  integer without a cast [-Wint-conversion]
>     return callee (first, second, third);
>                           ^~~~~~
>  test.c:1:41: note: expected 'const char *' but argument is of type 'int'
>   extern int callee (int one, const char *two, float three);
>                               ~~~~~~~~~~~~^~~
> 
> making the problem more obvious to the user.

I'm not sure why you'd point at the formal parameter name, which isn't significant and might not be present.  The issue is with the type, so pointing at the type ("const char *") would seem more obvious.

	paul


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