diff options
-rw-r--r-- | gcc/rust/expand/rust-macro-expand.cc | 6 | ||||
-rw-r--r-- | gcc/rust/parse/rust-parse.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/rust/execute/torture/macros27.rs | 24 |
3 files changed, 26 insertions, 6 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index 6227344..2620fea 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -490,11 +490,7 @@ MacroExpander::match_fragment (Parser<MacroInvocLexer> &parser, // is meta attributes? case AST::MacroFragSpec::META: - // parser.parse_inner_attribute ? - // parser.parse_outer_attribute ? - // parser.parse_attribute_body ? - // parser.parse_doc_comment ? - gcc_unreachable (); + parser.parse_attribute_body (); break; case AST::MacroFragSpec::TT: diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h index 88bd311..1362c56 100644 --- a/gcc/rust/parse/rust-parse.h +++ b/gcc/rust/parse/rust-parse.h @@ -143,6 +143,7 @@ public: AST::Visibility parse_visibility (); std::unique_ptr<AST::IdentifierPattern> parse_identifier_pattern (); std::unique_ptr<AST::TokenTree> parse_token_tree (); + AST::Attribute parse_attribute_body (); private: void skip_after_semicolon (); @@ -162,7 +163,6 @@ private: AST::Attribute parse_inner_attribute (); AST::AttrVec parse_outer_attributes (); AST::Attribute parse_outer_attribute (); - AST::Attribute parse_attribute_body (); std::unique_ptr<AST::AttrInput> parse_attr_input (); AST::Attribute parse_doc_comment (); diff --git a/gcc/testsuite/rust/execute/torture/macros27.rs b/gcc/testsuite/rust/execute/torture/macros27.rs new file mode 100644 index 0000000..d515bb2 --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/macros27.rs @@ -0,0 +1,24 @@ +// { dg-additional-options "-frust-cfg=A" } + +macro_rules! attr { + (#[$attr:meta] $s:stmt) => { + #[$attr] + $s; + }; +} + +fn main() -> i32 { + let mut a = 0; + + attr! { + #[cfg(A)] + a = 3 + }; + + attr! { + #[cfg(B)] + a = 40 + }; + + a - 3 +} |