https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119117

--- Comment #6 from Yavor Doganov <yavor at gnu dot org> ---
(In reply to Andrew Pinski from comment #4)
> >This got broken by the C2y if declarations implementation (PR c/117019, 
> >commit 440be01).
> 
> No it was broken before that; just now exposed by it because it thinks
> `unknown * b` will be a declaration but in this case unknown is the same as
> `self->unknown`.

Right, your test program clearly demonstrates that this is an old issue.  The
second error message was specific so it pointed me to PR c/117019.

> But the issue is here:
> ```
>   /* Try to detect an unknown type name when we have "A B" or "A *B".  */
>   if (c_parser_peek_token (parser)->type == CPP_NAME
>       && c_parser_peek_token (parser)->id_kind == C_ID_ID
>       && (c_parser_peek_2nd_token (parser)->type == CPP_NAME
>           || c_parser_peek_2nd_token (parser)->type == CPP_MULT)
>       && (!nested || !lookup_name (c_parser_peek_token (parser)->value)))
> 
> ```

Thanks for the pointer.  If I adjust the condition here it fails later in
c_parser_declspecs.  If I handle it there too (by setting t.spec to the return
value of objc_lookup_ivar if it's not NULL) I get an error in
c_parser_direct_declarator, in the C_DTR_NORMAL case.  If I ignore it for
Objective-C (which is wrong) your program compiles but mine does not.

So I suggest a general approach as in the attached patch.  The test program is
your program with one additional statement.

Reply via email to