On Tue, 22 Oct 2024, Jakub Jelinek wrote:

> Sorry for rushing the previous patch too much, turns out I was wrong,
> given that the c_parser_peek_nth_token numbering is 1 based, we can peek
> also with c_parser_peek_nth_token (parser, 4) and the loop actually peeked
> just at 3 tokens, not 4.
> 
> So, I think it is better to revert the previous patch (but keep the new
> test) and instead peek the 4th non-raw token, which is what the following
> patch does.
> 
> Additionally, PR117190 shows one further spot which missed the peek of
> the token after CPP_COMMA, in case it is incomplete array with exactly 65
> elements with redundant comma after it, which this patch handles too.
> 
> Bootstrapped/regtested on x86_64-linux, i686-linux, powerpc64le-linux
> and powerpc64-linux, ok for trunk?
> 
> 2024-10-22  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR c/117190
> gcc/c/
>       * c-parser.cc (c_parser_initval): Revert 2024-10-17 changes.
>       Instead peek the 4th token and if it is not CPP_NUMBER,
>       handle it like 3rd token CPP_CLOSE_BRACE for orig_len == INT_MAX.
>       Also, check (2 + 2 * i)th raw token for the orig_len == INT_MAX
>       case and punt if it is not CPP_NUMBER.
> gcc/testsuite/
>       * c-c++-common/init-5.c: New test.

OK.

-- 
Joseph S. Myers
josmy...@redhat.com

Reply via email to