diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-05-20 15:28:19 +0200 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-06-12 09:11:18 +0000 |
commit | 8de769bfc570c2fe6392f54092aaf17b90e22813 (patch) | |
tree | 56fdd89fca8af98340ec1d66466131969c1a9519 /gcc/rust/parse/rust-parse-impl.h | |
parent | a45362e582e24f7997edc25dde660297bde710f5 (diff) | |
download | gcc-8de769bfc570c2fe6392f54092aaf17b90e22813.zip gcc-8de769bfc570c2fe6392f54092aaf17b90e22813.tar.gz gcc-8de769bfc570c2fe6392f54092aaf17b90e22813.tar.bz2 |
Add outer attributes to struct expr fields
Struct fields can have outer attributes on their field for various
purpose, this behavior should be reflected upon struct expr fields.
gcc/rust/ChangeLog:
* ast/rust-ast-collector.cc (TokenCollector::visit): Output field
attributes.
* ast/rust-expr.h (class StructExprField): Add outer attributes member.
* parse/rust-parse-impl.h (Parser::parse_struct_expr_field): Parse
outer attributes and store them in the appropriate AST node.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 3548fcc..8dc8b1a 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -11699,6 +11699,7 @@ template <typename ManagedTokenSource> std::unique_ptr<AST::StructExprField> Parser<ManagedTokenSource>::parse_struct_expr_field () { + AST::AttrVec outer_attrs = parse_outer_attributes (); const_TokenPtr t = lexer.peek_token (); switch (t->get_id ()) { @@ -11724,6 +11725,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_field () return std::unique_ptr<AST::StructExprFieldIdentifierValue> ( new AST::StructExprFieldIdentifierValue (std::move (ident), std::move (expr), + std::move (outer_attrs), t->get_locus ())); } else @@ -11734,6 +11736,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_field () return std::unique_ptr<AST::StructExprFieldIdentifier> ( new AST::StructExprFieldIdentifier (std::move (ident), + std::move (outer_attrs), t->get_locus ())); } case INT_LITERAL: { @@ -11761,6 +11764,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_field () return std::unique_ptr<AST::StructExprFieldIndexValue> ( new AST::StructExprFieldIndexValue (index, std::move (expr), + std::move (outer_attrs), t->get_locus ())); } case DOT_DOT: @@ -14082,6 +14086,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_struct_partial ( /* technically this would give a struct base-only struct, but this * algorithm should work too. As such, AST type not happening. */ case IDENTIFIER: + case HASH: case INT_LITERAL: { // struct with struct expr fields |