diff options
author | Thomas Young <wenzhang5800@gmail.com> | 2021-06-27 00:05:04 +0800 |
---|---|---|
committer | Thomas Young <wenzhang5800@gmail.com> | 2021-06-27 01:08:22 +0800 |
commit | 6952f9871f74f60090fa311c709bf66c4bb3a3d9 (patch) | |
tree | 63059318133d2d806ac3928f3f76db8a5bc4f02b | |
parent | 51d86210d3dcbbf4dea14149f90ad9087b006f6a (diff) | |
download | gcc-6952f9871f74f60090fa311c709bf66c4bb3a3d9.zip gcc-6952f9871f74f60090fa311c709bf66c4bb3a3d9.tar.gz gcc-6952f9871f74f60090fa311c709bf66c4bb3a3d9.tar.bz2 |
mark live symbol in break expr
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive.h | 11 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/break_function.rs | 10 |
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h index 67dd76a..27dfe36 100644 --- a/gcc/rust/lint/rust-lint-marklive.h +++ b/gcc/rust/lint/rust-lint-marklive.h @@ -103,6 +103,17 @@ public: } } + void visit (HIR::LoopExpr &expr) override + { + expr.get_loop_block ()->accept_vis (*this); + } + + void visit (HIR::BreakExpr &expr) override + { + if (expr.has_break_expr ()) + expr.get_expr ()->accept_vis (*this); + } + void visit (HIR::Function &function) override { function.get_definition ().get ()->accept_vis (*this); diff --git a/gcc/testsuite/rust/compile/torture/break_function.rs b/gcc/testsuite/rust/compile/torture/break_function.rs new file mode 100644 index 0000000..043e91c --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/break_function.rs @@ -0,0 +1,10 @@ +fn foo() -> i32 { + 1 +} + +fn main() { + let _a = loop { + break foo(); + }; +} +
\ No newline at end of file |