[C PATCH] Add 'aka's on type printing in diagnostics

Jeff Law law@redhat.com
Tue Nov 4 22:35:00 GMT 2014


On 10/25/14 09:16, Marek Polacek wrote:
> This patch teaches the compiler to also print the typedef-stripped
> version of a type when appropriate.  C++ FE does this for a few
> years now.  With this patch we're able to say
> note: expected 'B * {aka struct A *}' but argument is of type 'struct B *'
> Compare that with
> note: expected 'struct B *' but argument is of type 'struct B *'
> that we output until recently.
>
> We must be careful not to print the typedef-stripped part if it's
> identical to the non-stripped part.  I worked it out by using
> a temporary c_pretty_printer and an obstack (C++'s type_to_string
> uses an obstack too).
>
> Bootstrapped/regtested on x86_64-linux and ppc64-linux, ok for trunk?
>
> 2014-10-25  Marek Polacek  <polacek@redhat.com>
>
> 	* c-objc-common.c (c_tree_printer) <case 'T'>: For a typedef name,
> 	print the stripped version as well, if they're not the same.
>
> 	* gcc.dg/diag-aka-1.c: New test.
> 	* gcc.dg/pr13804-1.c: Adjust dg-error.
> 	* gcc.dg/redecl-14.c: Likewise.
> 	* gcc.dg/pr56980.c: Adjust dg-message.
OK.

Jeff



More information about the Gcc-patches mailing list