aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/expand/rust-macro-expand.cc
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-03-14 10:36:09 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2022-03-14 11:21:20 +0100
commit02887c88f57834e3c5b20e98e15710fc7e43562d (patch)
tree7a0a4ed8a76d10db85fd6b6d3ee34d752095d1b4 /gcc/rust/expand/rust-macro-expand.cc
parent41f402f0b19c7e4f19f8d4d65d15223d2752f302 (diff)
downloadgcc-02887c88f57834e3c5b20e98e15710fc7e43562d.zip
gcc-02887c88f57834e3c5b20e98e15710fc7e43562d.tar.gz
gcc-02887c88f57834e3c5b20e98e15710fc7e43562d.tar.bz2
macros: Do not try and re-expand if depth has exceeded recursion limit
We need to limit the amount of times that macro get expanded recursively during macro-expansion. This limits the amount of times an ASTFragment can be visited by simply incrementing the depth when setting a fragment, and decreasing it when taking one. This way, recursive expansion which happens at the expansion level (instead of the matching level) will still get caught
Diffstat (limited to 'gcc/rust/expand/rust-macro-expand.cc')
-rw-r--r--gcc/rust/expand/rust-macro-expand.cc3
1 files changed, 1 insertions, 2 deletions
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc
index 22ba1d8a..b5f22d3 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -379,10 +379,9 @@ MacroExpander::expand_crate ()
// mark for stripping if required
item->accept_vis (attr_visitor);
- auto fragment = take_expanded_fragment ();
+ auto fragment = take_expanded_fragment (attr_visitor);
if (fragment.should_expand ())
{
- fragment.accept_vis (attr_visitor);
// Remove the current expanded invocation
it = items.erase (it);
for (auto &node : fragment.get_nodes ())