aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Young <wenzhang5800@gmail.com>2021-06-27 00:52:46 +0800
committerThomas Young <wenzhang5800@gmail.com>2021-06-27 01:18:59 +0800
commit348c893f9c56b1be8eeb1b843d239564567d00ee (patch)
tree2db2436bb33a7ce55f882dc7a53f7c042b72287c /gcc
parenta89ee61180a95a9d67f074d5f165e33d8e345bc9 (diff)
downloadgcc-348c893f9c56b1be8eeb1b843d239564567d00ee.zip
gcc-348c893f9c56b1be8eeb1b843d239564567d00ee.tar.gz
gcc-348c893f9c56b1be8eeb1b843d239564567d00ee.tar.bz2
mark live symbol in while expr
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/lint/rust-lint-marklive.h6
-rw-r--r--gcc/testsuite/rust/compile/torture/while_function.rs10
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h
index 4952c9a..529d189 100644
--- a/gcc/rust/lint/rust-lint-marklive.h
+++ b/gcc/rust/lint/rust-lint-marklive.h
@@ -114,6 +114,12 @@ public:
expr.get_expr ()->accept_vis (*this);
}
+ void visit (HIR::WhileLoopExpr &expr) override
+ {
+ expr.get_loop_block ()->accept_vis (*this);
+ expr.get_predicate_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/while_function.rs b/gcc/testsuite/rust/compile/torture/while_function.rs
new file mode 100644
index 0000000..014db90
--- /dev/null
+++ b/gcc/testsuite/rust/compile/torture/while_function.rs
@@ -0,0 +1,10 @@
+fn foo() {}
+fn bar() -> i32 { return 10; }
+
+fn main() {
+ let mut i = 1;
+ while i < bar() {
+ foo();
+ i += 1;
+ }
+}