On Thu, 2017-07-13 at 16:18 +0200, Marek Polacek wrote:
> This patch improves diagnostic in the C FE by printing the types when
> reporting
> a problem with a conversion. E.g., instead of
>
> warning: assignment from incompatible pointer type
>
> you'll now get
>
> warning: assignment to 'int *' from incompatible pointer type 'char
> *'
>
> or instead of
>
> warning: initialization makes integer from pointer without a cast
>
> this
>
> warning: initialization of 'int *' from 'int' makes pointer from
> integer without a cast
>
> I've been wanting this for a long time and here it is. Two snags: I
> had to
> make pedwarn_init to take '...' for which I had to introduce
> emit_diagnostic_valist; you can't pass varargs from one vararg
> function to
> another vararg function (and a macro with __VA_ARGS__ didn't work
> here).
The changes to diagnostic-core.h and diagnostic.c are OK.
> Also,
> PEDWARN_FOR_ASSIGNMENT didn't work with the addition of printing TYPE
> and
> RHSTYPE so I just decided to unroll the macro instead of making it
> even more
> ugly.
> This patch is long but it's mainly because of the testsuite fallout.
The comment by PEDWARN_FOR_ASSIGNMENT says:
/* This macro is used to emit diagnostics to ensure that all format
strings are complete sentences, visible to gettext and checked
at
compile time. */
I wonder if it's possible to convert it to an inline function to get
the same test coverage, without unrolling the macro?
[...snip...]
Dave