diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-04-25 11:10:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 11:10:22 +0000 |
commit | 2b1cb4ba8693e2c148e7aa406b4f03d34ffc0439 (patch) | |
tree | 7c0e5170858b3abc2c384f62b308103e9cd0dc6d /gcc/rust | |
parent | d54ca716854b30c6a6431310d7f1726073ecee25 (diff) | |
parent | e26b95f64a0f450199b3a5f58db68dfd0fb585b5 (diff) | |
download | gcc-2b1cb4ba8693e2c148e7aa406b4f03d34ffc0439.zip gcc-2b1cb4ba8693e2c148e7aa406b4f03d34ffc0439.tar.gz gcc-2b1cb4ba8693e2c148e7aa406b4f03d34ffc0439.tar.bz2 |
Merge #1161
1161: Implement macro expansion for ComparisonExpr, LazyBooleanExpr, AssignmentExpr r=CohenArthur a=antego
Following up on https://github.com/Rust-GCC/gccrs/issues/1141
Currently the macro expansion doesn't work for ComparisonExpr, LazyBooleanExpr, AssignmentExpr. To fix this, I just copied the code from the `ArithmeticOrLogicalExpr` and it seemed to work. I don't like the code duplication, happy to try refactoring it into a separate function.
Will work on the macro expansion in the `if` expressions next.
Co-authored-by: antego <antego@users.noreply.github.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/expand/rust-attribute-visitor.cc | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/gcc/rust/expand/rust-attribute-visitor.cc b/gcc/rust/expand/rust-attribute-visitor.cc index 859ae7e..e420d09 100644 --- a/gcc/rust/expand/rust-attribute-visitor.cc +++ b/gcc/rust/expand/rust-attribute-visitor.cc @@ -643,10 +643,19 @@ AttrVisitor::visit (AST::ComparisonExpr &expr) /* should have no possibility for outer attrs as would be parsed * with outer expr */ - expr.get_left_expr ()->accept_vis (*this); + auto &l_expr = expr.get_left_expr (); + l_expr->accept_vis (*this); + auto l_fragment = expander.take_expanded_fragment (*this); + if (l_fragment.should_expand ()) + l_expr = l_fragment.take_expression_fragment (); + /* should syntactically not have outer attributes, though this may * not have worked in practice */ - expr.get_right_expr ()->accept_vis (*this); + auto &r_expr = expr.get_right_expr (); + r_expr->accept_vis (*this); + auto r_fragment = expander.take_expanded_fragment (*this); + if (r_fragment.should_expand ()) + r_expr = r_fragment.take_expression_fragment (); // ensure that they are not marked for strip if (expr.get_left_expr ()->is_marked_for_strip ()) @@ -667,10 +676,19 @@ AttrVisitor::visit (AST::LazyBooleanExpr &expr) /* should have no possibility for outer attrs as would be parsed * with outer expr */ - expr.get_left_expr ()->accept_vis (*this); + auto &l_expr = expr.get_left_expr (); + l_expr->accept_vis (*this); + auto l_fragment = expander.take_expanded_fragment (*this); + if (l_fragment.should_expand ()) + l_expr = l_fragment.take_expression_fragment (); + /* should syntactically not have outer attributes, though this may * not have worked in practice */ - expr.get_right_expr ()->accept_vis (*this); + auto &r_expr = expr.get_right_expr (); + r_expr->accept_vis (*this); + auto r_fragment = expander.take_expanded_fragment (*this); + if (r_fragment.should_expand ()) + r_expr = r_fragment.take_expression_fragment (); // ensure that they are not marked for strip if (expr.get_left_expr ()->is_marked_for_strip ()) @@ -718,10 +736,19 @@ AttrVisitor::visit (AST::AssignmentExpr &expr) /* should have no possibility for outer attrs as would be parsed * with outer expr */ - expr.get_left_expr ()->accept_vis (*this); + auto &l_expr = expr.get_left_expr (); + l_expr->accept_vis (*this); + auto l_fragment = expander.take_expanded_fragment (*this); + if (l_fragment.should_expand ()) + l_expr = l_fragment.take_expression_fragment (); + /* should syntactically not have outer attributes, though this may * not have worked in practice */ - expr.get_right_expr ()->accept_vis (*this); + auto &r_expr = expr.get_right_expr (); + r_expr->accept_vis (*this); + auto r_fragment = expander.take_expanded_fragment (*this); + if (r_fragment.should_expand ()) + r_expr = r_fragment.take_expression_fragment (); // ensure that they are not marked for strip if (expr.get_left_expr ()->is_marked_for_strip ()) |