public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] gengtype: Handle braced initialisers in structs
Date: Tue, 27 Jun 2023 06:38:11 +0100	[thread overview]
Message-ID: <mptcz1ha2ik.fsf@arm.com> (raw)

I have a patch that adds braced initializers 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.

Tested on aarch64-linux-gnu & x86_&4-linux-gnu.  OK to install?

Richard


gcc/
	* gengtype-parse.cc (consume_until_comma_or_eos): Parse "= { ... }"
	as a probable initializer rather than a probable complete statement.
---
 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;
-- 
2.25.1


             reply	other threads:[~2023-06-27  5:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27  5:38 Richard Sandiford [this message]
2023-06-27  7:20 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mptcz1ha2ik.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).