public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2118] gengtype: Handle braced initialisers in structs
@ 2023-06-27  7:54 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2023-06-27  7:54 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ebe7c586f62b1c5218b19c3c6853163287b3c887

commit r14-2118-gebe7c586f62b1c5218b19c3c6853163287b3c887
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Tue Jun 27 08:54:20 2023 +0100

    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:
---
 gcc/gengtype-parse.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/gengtype-parse.cc b/gcc/gengtype-parse.cc
index 2b2156c5f45..19184d77899 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-27  7:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27  7:54 [gcc r14-2118] gengtype: Handle braced initialisers in structs Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).