Skip to content

Commit 19c5dde

Browse files
committed
When we expand a macro we must visit it to ensure any cfg expansions or recursive macro expansion is required
1 parent 2c03f34 commit 19c5dde

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

gcc/rust/expand/rust-macro-expand.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,6 +2535,11 @@ class AttrVisitor : public AST::ASTVisitor
25352535
// I don't think any macro token trees can be stripped in any way
25362536

25372537
expander.expand_invoc (macro_invoc);
2538+
2539+
// we need to visit the expanded fragments since it may need cfg expansion
2540+
// and it may be recursive
2541+
for (auto &node : macro_invoc.get_fragment ().get_nodes ())
2542+
node.accept_vis (*this);
25382543
}
25392544

25402545
void visit (AST::MetaItemPath &) override {}
@@ -3401,11 +3406,16 @@ MacroExpander::match_fragment (Parser<MacroInvocLexer> &parser,
34013406

34023407
// is meta attributes?
34033408
case AST::MacroFragSpec::META:
3409+
// parser.parse_inner_attribute ?
3410+
// parser.parse_outer_attribute ?
3411+
// parser.parse_attribute_body ?
3412+
// parser.parse_doc_comment ?
34043413
gcc_unreachable ();
34053414
break;
34063415

34073416
// what is TT?
34083417
case AST::MacroFragSpec::TT:
3418+
// parser.parse_token_tree() ?
34093419
gcc_unreachable ();
34103420
break;
34113421

@@ -3425,8 +3435,7 @@ MacroExpander::match_matcher (Parser<MacroInvocLexer> &parser,
34253435
{
34263436
if (depth_exceeds_recursion_limit ())
34273437
{
3428-
// FIXME location
3429-
rust_error_at (Location (), "reached recursion limit");
3438+
rust_error_at (matcher.get_match_locus (), "reached recursion limit");
34303439
return false;
34313440
}
34323441

0 commit comments

Comments
 (0)