diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-03-25 11:13:29 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-03-25 11:22:17 +0100 |
commit | 2249a4d5125689e9012a866537bade963317fab8 (patch) | |
tree | 71631a8bffd92767ef8c32e8393b9d3c48c9c493 /gcc | |
parent | 89ad4f21f25a2501bb9bb96338be4a6edb89bbcd (diff) | |
download | gcc-2249a4d5125689e9012a866537bade963317fab8.zip gcc-2249a4d5125689e9012a866537bade963317fab8.tar.gz gcc-2249a4d5125689e9012a866537bade963317fab8.tar.bz2 |
attributes: Allow stripping assignment expressions
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/expand/rust-attribute-visitor.cc | 8 | ||||
-rw-r--r-- | gcc/rust/expand/rust-attribute-visitor.h | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/gcc/rust/expand/rust-attribute-visitor.cc b/gcc/rust/expand/rust-attribute-visitor.cc index 3de6608..8f2a6c7 100644 --- a/gcc/rust/expand/rust-attribute-visitor.cc +++ b/gcc/rust/expand/rust-attribute-visitor.cc @@ -628,8 +628,12 @@ AttrVisitor::visit (AST::TypeCastExpr &expr) void AttrVisitor::visit (AST::AssignmentExpr &expr) { - /* outer attributes never allowed before these. while cannot strip - * two direct descendant expressions, can strip ones below that */ + expander.expand_cfg_attrs (expr.get_outer_attrs ()); + if (expander.fails_cfg_with_expand (expr.get_outer_attrs ())) + { + expr.mark_for_strip (); + return; + } /* should have no possibility for outer attrs as would be parsed * with outer expr */ diff --git a/gcc/rust/expand/rust-attribute-visitor.h b/gcc/rust/expand/rust-attribute-visitor.h index 6da6583..1c6410d 100644 --- a/gcc/rust/expand/rust-attribute-visitor.h +++ b/gcc/rust/expand/rust-attribute-visitor.h @@ -71,8 +71,12 @@ public: it = values.erase (it); for (auto &node : fragment.get_nodes ()) { - it = values.insert (it, extractor (node)); - it++; + auto new_node = extractor (node); + if (new_node != nullptr && !new_node->is_marked_for_strip ()) + { + it = values.insert (it, std::move (new_node)); + it++; + } } } else if (value->is_marked_for_strip ()) |