public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] When we expand a macro we must visit it to ensure any cfg expansions or recursive macro expansion is
@ 2022-06-08 12:07 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:07 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:19c5dde80f28c67f657775f770922783faff4b89
commit 19c5dde80f28c67f657775f770922783faff4b89
Author: Philip Herron <philip.herron@embecosm.com>
Date: Thu Feb 17 10:10:15 2022 +0000
When we expand a macro we must visit it to ensure any cfg expansions or recursive macro expansion is required
Diff:
---
gcc/rust/expand/rust-macro-expand.cc | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc
index 306b2e53be1..bce524611cb 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -2535,6 +2535,11 @@ public:
// I don't think any macro token trees can be stripped in any way
expander.expand_invoc (macro_invoc);
+
+ // we need to visit the expanded fragments since it may need cfg expansion
+ // and it may be recursive
+ for (auto &node : macro_invoc.get_fragment ().get_nodes ())
+ node.accept_vis (*this);
}
void visit (AST::MetaItemPath &) override {}
@@ -3401,11 +3406,16 @@ MacroExpander::match_fragment (Parser<MacroInvocLexer> &parser,
// is meta attributes?
case AST::MacroFragSpec::META:
+ // parser.parse_inner_attribute ?
+ // parser.parse_outer_attribute ?
+ // parser.parse_attribute_body ?
+ // parser.parse_doc_comment ?
gcc_unreachable ();
break;
// what is TT?
case AST::MacroFragSpec::TT:
+ // parser.parse_token_tree() ?
gcc_unreachable ();
break;
@@ -3425,8 +3435,7 @@ MacroExpander::match_matcher (Parser<MacroInvocLexer> &parser,
{
if (depth_exceeds_recursion_limit ())
{
- // FIXME location
- rust_error_at (Location (), "reached recursion limit");
+ rust_error_at (matcher.get_match_locus (), "reached recursion limit");
return false;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:07 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:07 [gcc/devel/rust/master] When we expand a macro we must visit it to ensure any cfg expansions or recursive macro expansion is 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).