public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] attributes: Allow stripping assignment expressions
@ 2022-06-08 12:24 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2249a4d5125689e9012a866537bade963317fab8
commit 2249a4d5125689e9012a866537bade963317fab8
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Fri Mar 25 11:13:29 2022 +0100
attributes: Allow stripping assignment expressions
Diff:
---
gcc/rust/expand/rust-attribute-visitor.cc | 8 ++++++--
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 3de660897ca..8f2a6c7fc5f 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 6da6583030c..1c6410d2304 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 ())
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:24 [gcc/devel/rust/master] attributes: Allow stripping assignment expressions Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).