public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] expand/attr-visitor: recursively expand the macros if needed
@ 2022-07-22 13:34 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-07-22 13:34 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0340a567fedab5f902febcea8f415943ca85b330

commit 0340a567fedab5f902febcea8f415943ca85b330
Author: liushuyu <liushuyu011@gmail.com>
Date:   Tue Jul 19 12:32:26 2022 -0600

    expand/attr-visitor: recursively expand the macros if needed
    
    Signed-off-by: Zixing Liu <liushuyu011@gmail.com>

Diff:
---
 gcc/rust/expand/rust-attribute-visitor.cc | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/expand/rust-attribute-visitor.cc b/gcc/rust/expand/rust-attribute-visitor.cc
index 6cd894d261e..bbcf2cbadd0 100644
--- a/gcc/rust/expand/rust-attribute-visitor.cc
+++ b/gcc/rust/expand/rust-attribute-visitor.cc
@@ -3431,8 +3431,17 @@ void
 AttrVisitor::maybe_expand_expr (std::unique_ptr<AST::Expr> &expr)
 {
   auto fragment = expander.take_expanded_fragment (*this);
-  if (fragment.should_expand ())
-    expr = fragment.take_expression_fragment ();
+  unsigned int original_depth = expander.expansion_depth;
+  while (fragment.should_expand ())
+    {
+      expr = fragment.take_expression_fragment ();
+      expander.expansion_depth++;
+      auto new_fragment = expander.take_expanded_fragment (*this);
+      if (new_fragment.is_error ())
+	break;
+      fragment = std::move (new_fragment);
+    }
+  expander.expansion_depth = original_depth;
 }
 
 void


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-22 13:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 13:34 [gcc/devel/rust/master] expand/attr-visitor: recursively expand the macros if needed 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).