diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2024-05-20 15:28:19 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-17 16:35:32 +0100 |
commit | fc1712be9ffde5049cd35aa281a931bc64775b68 (patch) | |
tree | 843f4bbd75c0754539196a65b147208110425c4b /gcc/rust/parse/rust-parse-impl.h | |
parent | 997fa94b5276766acb40dd502eb606d5e220e918 (diff) | |
download | gcc-fc1712be9ffde5049cd35aa281a931bc64775b68.zip gcc-fc1712be9ffde5049cd35aa281a931bc64775b68.tar.gz gcc-fc1712be9ffde5049cd35aa281a931bc64775b68.tar.bz2 |
gccrs: 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 6eb1955..e2a9b19 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 |