This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C PATCH] Clamp down "incomplete type" error (PR c/63543)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: Marek Polacek <polacek at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 15 Oct 2014 21:57:19 +0000
- Subject: Re: [C PATCH] Clamp down "incomplete type" error (PR c/63543)
- Authentication-results: sourceware.org; auth=none
- References: <20141015172244 dot GE10501 at redhat dot com> <Pine dot LNX dot 4 dot 64 dot 1410152143150 dot 11645 at digraph dot polyomino dot org dot uk> <543EEBA4 dot 2030907 at redhat dot com>
On Wed, 15 Oct 2014, Jeff Law wrote:
> On 10/15/14 15:46, 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.
> Isn't slamming error_mark_node well established at this point? I fact I
> recall seeing it documented to be used in this kind of way to prevent future
> errors.
Returning error_mark_node for the erroneous expression, yes - the
pre-existing code already does that in this case. The problem is that the
insertion of error_mark_node into the type will lead to other uses of that
type (including ones that have already been processed without errors)
being affected, and the type itself isn't erroneous. Indeed, the patch
would create a "pointer-to-error_mark" type node, which is not something
code in GCC would ever normally expect to handle
(build_pointer_type_for_mode just returns error_mark_node if passed
error_mark_node, so you can't get a POINTER_TYPE whose target is
error_mark_node that way).
--
Joseph S. Myers
joseph@codesourcery.com