From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id A47053858D33; Tue, 27 Jun 2023 07:54:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A47053858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687852477; bh=B22EWkonmTc+B/HMx1JDBZDF+IOxm6jzatLaQEFGMqA=; h=From:To:Subject:Date:From; b=mRG5lmgrtum9hjfVO9qJztTYBkNLH3O5ALKQJrNR/QXhs1xu6XtkDZnWZ+D1YqRy0 qiz971cm8j3h4GzLdqo8i8AG4XM0y/Ss0/KCkOtPaIoCuahXdAgyO/YLhohA6+4t3m NWs0uS0Oq1uwgkoKbM7VZgwHEL/LWTuDcOxLfDRk= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Sandiford To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-2118] gengtype: Handle braced initialisers in structs X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/trunk X-Git-Oldrev: dd86a5a69cbda40cf76388a65d3317c91cb2b501 X-Git-Newrev: ebe7c586f62b1c5218b19c3c6853163287b3c887 Message-Id: <20230627075437.A47053858D33@sourceware.org> Date: Tue, 27 Jun 2023 07:54:37 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ebe7c586f62b1c5218b19c3c6853163287b3c887 commit r14-2118-gebe7c586f62b1c5218b19c3c6853163287b3c887 Author: Richard Sandiford 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;