public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] parser: Build ConstGenericParam properly
@ 2022-06-21 10:33 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-21 10:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:594854ec08cb10927f571885a0c7a4c1d47dfaf5

commit 594854ec08cb10927f571885a0c7a4c1d47dfaf5
Author: Arthur Cohen <arthur.cohen@embecosm.com>
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<ManagedTokenSource>::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<AST::Expr> 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<ManagedTokenSource>::parse_generic_param (EndTokenPred is_end_token)
 			     token_id_to_str (tok->get_id ()));
 	  }
 
-	// param = std::unique_ptr<AST::GenericParam> (const_generic)
+	param = std::unique_ptr<AST::ConstGenericParam> (
+	  new AST::ConstGenericParam (name_token->get_str (), std::move (type),
+				      std::move (default_expr),
+				      std::move (outer_attrs),
+				      token->get_locus ()));
 
 	break;
       }


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

only message in thread, other threads:[~2022-06-21 10:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 10:33 [gcc/devel/rust/master] parser: Build ConstGenericParam properly Thomas Schwinge

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).