* [PATCH] gengtype: Handle braced initialisers in structs
@ 2023-06-27 5:38 Richard Sandiford
2023-06-27 7:20 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2023-06-27 5:38 UTC (permalink / raw)
To: gcc-patches
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gengtype: Handle braced initialisers in structs
2023-06-27 5:38 [PATCH] gengtype: Handle braced initialisers in structs Richard Sandiford
@ 2023-06-27 7:20 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-06-27 7:20 UTC (permalink / raw)
To: Richard Sandiford, gcc-patches
On Tue, Jun 27, 2023 at 7:38 AM Richard Sandiford via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> 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?
OK.
> 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-27 7:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 5:38 [PATCH] gengtype: Handle braced initialisers in structs Richard Sandiford
2023-06-27 7:20 ` Richard Biener
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).