From: Pierre-Emmanuel Patry <[email protected]>

Those attribute may contain macros within their input that must be
expanded, hence why we must visit them.

gcc/rust/ChangeLog:

        * ast/rust-ast.h: Add helper to set a new attribute input.
        * expand/rust-expand-visitor.cc (ExpandVisitor::expand_inner_stmts):
        Visit builtin attributes.
        (ExpandVisitor::visit): Likewise.
        * resolve/rust-early-name-resolver-2.0.cc (Early::visit): Expand
        attribute input expr.

Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
---
 gcc/rust/ast/rust-ast.h                          | 5 +++++
 gcc/rust/expand/rust-expand-visitor.cc           | 4 +++-
 gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 2 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 4a1974d4d9d..f6b704507f7 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -632,6 +632,11 @@ public:
 
   AttrInput &get_attr_input () const { return *attr_input; }
 
+  void set_attr_input (std::unique_ptr<AST::AttrInput> input)
+  {
+    attr_input = std::move (input);
+  }
+
   /* e.g.:
       #![crate_type = "lib"]
       #[test]
diff --git a/gcc/rust/expand/rust-expand-visitor.cc 
b/gcc/rust/expand/rust-expand-visitor.cc
index c124f9ab937..16786e32e15 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -218,6 +218,7 @@ ExpandVisitor::expand_inner_items (
                {
                  if (is_builtin (current))
                    {
+                     visit (*attr_it);
                      attr_it++;
                    }
                  else
@@ -303,6 +304,7 @@ ExpandVisitor::expand_inner_stmts (AST::BlockExpr &expr)
                {
                  if (is_builtin (current))
                    {
+                     visit (*attr_it);
                      attr_it++;
                    }
                  else
@@ -586,7 +588,7 @@ ExpandVisitor::visit (AST::AttrInputLiteral &)
 void
 ExpandVisitor::visit (AST::AttrInputExpr &attr_input)
 {
-  reseat (attr_input.get_expr_ptr ());
+  maybe_expand_expr (attr_input.get_expr_ptr ());
 }
 
 void
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index 91ad82c8966..058207f1f4a 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -397,6 +397,8 @@ Early::visit (AST::Attribute &attr)
     {
       visit_non_builtin_attribute (attr, mappings, name);
     }
+
+  DefaultResolver::visit (attr);
 }
 
 void
-- 
2.50.1

Reply via email to