From b2fb51a2640b2529869542a305afba42cd83ff03 Mon Sep 17 00:00:00 2001 From: Thomas Young Date: Sun, 29 May 2022 13:00:00 +0800 Subject: Marklive: support arrayindex --- gcc/rust/lint/rust-lint-marklive.h | 6 ++++++ gcc/testsuite/rust/compile/torture/arrays_index3.rs | 15 +++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 gcc/testsuite/rust/compile/torture/arrays_index3.rs (limited to 'gcc') diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h index 529afa6..ef37e17 100644 --- a/gcc/rust/lint/rust-lint-marklive.h +++ b/gcc/rust/lint/rust-lint-marklive.h @@ -78,6 +78,12 @@ public: expr.get_internal_elements ()->accept_vis (*this); } + void visit (HIR::ArrayIndexExpr &expr) override + { + expr.get_array_expr ()->accept_vis (*this); + expr.get_index_expr ()->accept_vis (*this); + } + void visit (HIR::ArrayElemsValues &expr) override { for (auto &elem : expr.get_values ()) diff --git a/gcc/testsuite/rust/compile/torture/arrays_index3.rs b/gcc/testsuite/rust/compile/torture/arrays_index3.rs new file mode 100644 index 0000000..8fa0a22 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/arrays_index3.rs @@ -0,0 +1,15 @@ +fn foo() -> usize { + 1 +} + +fn bar() -> [i32; 1] { + [0] +} + + + +fn main() -> () { + let a = [10]; + let _b = a[foo()]; + let _c = bar()[foo()]; +} -- cgit v1.1