diff options
author | Thomas Young <wenzhang5800@gmail.com> | 2021-06-26 11:04:08 +0800 |
---|---|---|
committer | Thomas Young <wenzhang5800@gmail.com> | 2021-06-26 12:00:08 +0800 |
commit | c9cb0c3d446321e80b3c790b9ade0dda1574dc29 (patch) | |
tree | 292bc31e11d9af6518bfc250dadc7a38422f209d | |
parent | 8a458543eb3a2775adaa3ffcf16be7e24a3c7b21 (diff) | |
download | gcc-c9cb0c3d446321e80b3c790b9ade0dda1574dc29.zip gcc-c9cb0c3d446321e80b3c790b9ade0dda1574dc29.tar.gz gcc-c9cb0c3d446321e80b3c790b9ade0dda1574dc29.tar.bz2 |
mark live symbol in array expr
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive.h | 13 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/array_function.rs | 8 |
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 979ad77..46f0bb3 100644 --- a/gcc/rust/lint/rust-lint-marklive.h +++ b/gcc/rust/lint/rust-lint-marklive.h @@ -70,6 +70,19 @@ public: expr.get_expr_in_parens()->accept_vis(*this); } + void visit (HIR::ArrayExpr &expr) override + { + expr.get_internal_elements()->accept_vis(*this); + } + + void visit (HIR::ArrayElemsValues &expr) override + { + expr.iterate([&](HIR::Expr *expr) mutable -> bool { + expr->accept_vis(*this); + return true; + }); + } + void visit (HIR::BlockExpr &expr) override { expr.iterate_stmts ([&] (HIR::Stmt *s) mutable -> bool { diff --git a/gcc/testsuite/rust/compile/torture/array_function.rs b/gcc/testsuite/rust/compile/torture/array_function.rs new file mode 100644 index 0000000..4e2b2e0 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/array_function.rs @@ -0,0 +1,8 @@ +fn foo() -> i32 { + 1 +} + + +fn main() { + let _a: [i32; 1] = [foo()]; +}
\ No newline at end of file |