diff options
author | Thomas Young <wenzhang5800@gmail.com> | 2022-05-29 13:00:00 +0800 |
---|---|---|
committer | Thomas Young <wenzhang5800@gmail.com> | 2022-05-29 13:00:00 +0800 |
commit | b2fb51a2640b2529869542a305afba42cd83ff03 (patch) | |
tree | 7c54ccb1d94cf7aa86ca8ac92e0f3736e657e978 | |
parent | 7a94948e65db2fef6fd93c94e70ead168b71513d (diff) | |
download | gcc-b2fb51a2640b2529869542a305afba42cd83ff03.zip gcc-b2fb51a2640b2529869542a305afba42cd83ff03.tar.gz gcc-b2fb51a2640b2529869542a305afba42cd83ff03.tar.bz2 |
Marklive: support arrayindex
-rw-r--r-- | gcc/rust/lint/rust-lint-marklive.h | 6 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/arrays_index3.rs | 15 |
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 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()]; +} |