aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Young <wenzhang5800@gmail.com>2021-06-26 11:04:08 +0800
committerThomas Young <wenzhang5800@gmail.com>2021-06-26 12:00:08 +0800
commitc9cb0c3d446321e80b3c790b9ade0dda1574dc29 (patch)
tree292bc31e11d9af6518bfc250dadc7a38422f209d /gcc
parent8a458543eb3a2775adaa3ffcf16be7e24a3c7b21 (diff)
downloadgcc-c9cb0c3d446321e80b3c790b9ade0dda1574dc29.zip
gcc-c9cb0c3d446321e80b3c790b9ade0dda1574dc29.tar.gz
gcc-c9cb0c3d446321e80b3c790b9ade0dda1574dc29.tar.bz2
mark live symbol in array expr
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/lint/rust-lint-marklive.h13
-rw-r--r--gcc/testsuite/rust/compile/torture/array_function.rs8
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