From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 16411383541F; Fri, 22 Jul 2022 13:34:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16411383541F Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] expand/attr-visitor: recursively expand the macros if needed X-Act-Checkin: gcc X-Git-Author: liushuyu X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 903b7de01555f2e09df3ec3ccb0edcc3e77f9a5e X-Git-Newrev: 0340a567fedab5f902febcea8f415943ca85b330 Message-Id: <20220722133426.16411383541F@sourceware.org> Date: Fri, 22 Jul 2022 13:34:26 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2022 13:34:26 -0000 https://gcc.gnu.org/g:0340a567fedab5f902febcea8f415943ca85b330 commit 0340a567fedab5f902febcea8f415943ca85b330 Author: liushuyu Date: Tue Jul 19 12:32:26 2022 -0600 expand/attr-visitor: recursively expand the macros if needed Signed-off-by: Zixing Liu 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 &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