[C PATCH] Clamp down "incomplete type" error (PR c/63543)

Jeff Law law@redhat.com
Thu Oct 16 22:09:00 GMT 2014


On 10/16/14 11:20, Marek Polacek wrote:
> On Wed, Oct 15, 2014 at 09:46:20PM +0000, Joseph S. Myers wrote:
>> On Wed, 15 Oct 2014, Marek Polacek wrote:
>>
>>> We've got a complaint that the "dereferencing pointer to incomplete
>>> type" error is printed for all occurrences of the incomplete type,
>>> which is too verbose.  Also it'd be nicer to print the type as well.
>>> This patch fixes this; if we find an incomplete type, mark it with error
>>> node, then we don't print the error message more than once.
>>
>> I don't like this approach of modifying the type; type nodes are shared
>> objects and this could affect all sorts of other logic subsequently
>> working with the type.  I think there should be some sort of annotation of
>> the type (either in the type itself, or on the side) that *only* means an
>> error has been given for the type being incomplete, rather than inserting
>> error_mark_node into the type.
>
> I'm sorry.  Here is another version, which uses a lang flag to distinguish
> whether a "dereferencing incomplete..." error message has been given.
>
> One could argue that I should've named the lang flag e.g.
> C_TYPE_INCOMPLETE_ERROR_REPORTED, but I hope it can be reused in the
> future for some similar purpose.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2014-10-16  Marek Polacek  <polacek@redhat.com>
>
> 	PR c/63543
> 	* c-tree.h (C_TYPE_ERROR_REPORTED): Define.
> 	* c-typeck.c (build_indirect_ref): Don't print the "dereferencing..."
> 	error multiple times.  Print the type.
>
> 	* gcc.dg/pr63543.c: New test.
> 	* gcc.dg/array-8.c: Remove dg-error.
> 	* gcc.dg/pr48552-1.c: Remove and adjust dg-error.
> 	* gcc.dg/pr48552-2.c: Likewise.
OK.

It's probably safe to assume we'll find more uses for that flag.

jeff



More information about the Gcc-patches mailing list