aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-06-16 05:05:53 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2022-06-17 09:43:07 +0200
commit594854ec08cb10927f571885a0c7a4c1d47dfaf5 (patch)
tree581cf6e399375e3c26fe502bbec488f8a9dbb6b2 /gcc
parentd9fb7d06ca79e8c0f784da02696b436bc50e2f49 (diff)
downloadgcc-594854ec08cb10927f571885a0c7a4c1d47dfaf5.zip
gcc-594854ec08cb10927f571885a0c7a4c1d47dfaf5.tar.gz
gcc-594854ec08cb10927f571885a0c7a4c1d47dfaf5.tar.bz2
parser: Build ConstGenericParam properly
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 3a76d74..b9f031d 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;
}