Skip to content

Commit 2249a4d

Browse files
committed
attributes: Allow stripping assignment expressions
1 parent 89ad4f2 commit 2249a4d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

gcc/rust/expand/rust-attribute-visitor.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,12 @@ AttrVisitor::visit (AST::TypeCastExpr &expr)
628628
void
629629
AttrVisitor::visit (AST::AssignmentExpr &expr)
630630
{
631-
/* outer attributes never allowed before these. while cannot strip
632-
* two direct descendant expressions, can strip ones below that */
631+
expander.expand_cfg_attrs (expr.get_outer_attrs ());
632+
if (expander.fails_cfg_with_expand (expr.get_outer_attrs ()))
633+
{
634+
expr.mark_for_strip ();
635+
return;
636+
}
633637

634638
/* should have no possibility for outer attrs as would be parsed
635639
* with outer expr */

gcc/rust/expand/rust-attribute-visitor.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ class AttrVisitor : public AST::ASTVisitor
7171
it = values.erase (it);
7272
for (auto &node : fragment.get_nodes ())
7373
{
74-
it = values.insert (it, extractor (node));
75-
it++;
74+
auto new_node = extractor (node);
75+
if (new_node != nullptr && !new_node->is_marked_for_strip ())
76+
{
77+
it = values.insert (it, std::move (new_node));
78+
it++;
79+
}
7680
}
7781
}
7882
else if (value->is_marked_for_strip ())

0 commit comments

Comments
 (0)