]> gcc.gnu.org Git - gcc.git/commitdiff
gengtype: Handle braced initialisers in structs
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 27 Jun 2023 07:54:20 +0000 (08:54 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 27 Jun 2023 07:54:20 +0000 (08:54 +0100)
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.

gcc/gengtype-parse.cc

index 2b2156c5f4523ef2d4427b1b50ffabf80038cdf0..19184d77899c0465e2654fa74ed4c0f4202ac95b 100644 (file)
@@ -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;
This page took 0.059227 seconds and 5 git commands to generate.