From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id B027338708FC; Tue, 21 Jun 2022 10:33:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B027338708FC Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] parser: Build ConstGenericParam properly X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: d9fb7d06ca79e8c0f784da02696b436bc50e2f49 X-Git-Newrev: 594854ec08cb10927f571885a0c7a4c1d47dfaf5 Message-Id: <20220621103334.B027338708FC@sourceware.org> Date: Tue, 21 Jun 2022 10:33:34 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2022 10:33:34 -0000 https://gcc.gnu.org/g:594854ec08cb10927f571885a0c7a4c1d47dfaf5 commit 594854ec08cb10927f571885a0c7a4c1d47dfaf5 Author: Arthur Cohen Date: Thu Jun 16 05:05:53 2022 +0200 parser: Build ConstGenericParam properly Diff: --- gcc/rust/parse/rust-parse-impl.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 3a76d748d6a..b9f031d0049 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -2868,24 +2868,22 @@ Parser::parse_generic_param (EndTokenPred is_end_token) case CONST: { lexer.skip_token (); - auto name = expect_token (IDENTIFIER); + auto name_token = expect_token (IDENTIFIER); - if (!name || !expect_token (COLON)) + if (!name_token || !expect_token (COLON)) return nullptr; auto type = parse_type (); if (!type) return nullptr; - // FIXME: instantiate proper AST::ConstGeneric class here - // auto const_generic = new ... - // optional default value + std::unique_ptr default_expr = nullptr; if (lexer.peek_token ()->get_id () == EQUAL) { lexer.skip_token (); auto tok = lexer.peek_token (); - auto default_expr = parse_const_generic_expression (); + default_expr = parse_const_generic_expression (); if (!default_expr) rust_error_at (tok->get_locus (), @@ -2895,7 +2893,11 @@ Parser::parse_generic_param (EndTokenPred is_end_token) token_id_to_str (tok->get_id ())); } - // param = std::unique_ptr (const_generic) + param = std::unique_ptr ( + new AST::ConstGenericParam (name_token->get_str (), std::move (type), + std::move (default_expr), + std::move (outer_attrs), + token->get_locus ())); break; }