From: Richard Sandiford Date: Tue, 27 Jun 2023 07:54:20 +0000 (+0100) Subject: gengtype: Handle braced initialisers in structs X-Git-Tag: basepoints/gcc-15~8021 X-Git-Url: https://gcc.gnu.org/git/?a=commitdiff_plain;h=ebe7c586f62b1c5218b19c3c6853163287b3c887;p=gcc.git gengtype: Handle braced initialisers in structs I have a patch that adds braced initialisers to a GTY structure. gengtype didn't accept that, because it parsed the "{ ... }" in " = { ... };" as the end of a statement (as "{ ... }" would be in a function definition) and so it didn't expect the following ";". This patch explicitly handles initialiser-like sequences. Arguably, the parser should also skip redundant ";", but that feels more like a workaround rather than the real fix. gcc/ * gengtype-parse.cc (consume_until_comma_or_eos): Parse "= { ... }" as a probable initializer rather than a probable complete statement. --- diff --git a/gcc/gengtype-parse.cc b/gcc/gengtype-parse.cc index 2b2156c5f452..19184d77899c 100644 --- a/gcc/gengtype-parse.cc +++ b/gcc/gengtype-parse.cc @@ -450,6 +450,12 @@ consume_until_comma_or_eos () parse_error ("unexpected end of file while scanning for ',' or ';'"); return false; + case '=': + advance (); + if (token () == '{') + consume_balanced ('{', '}'); + break; + default: advance (); break;