diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-06-01 08:33:59 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 08:33:59 +0000 |
commit | 998f1f73c2626f7ffa9655058e306b7f4e07c584 (patch) | |
tree | 7c54ccb1d94cf7aa86ca8ac92e0f3736e657e978 /gcc | |
parent | 7a94948e65db2fef6fd93c94e70ead168b71513d (diff) | |
parent | b2fb51a2640b2529869542a305afba42cd83ff03 (diff) | |
download | gcc-998f1f73c2626f7ffa9655058e306b7f4e07c584.zip gcc-998f1f73c2626f7ffa9655058e306b7f4e07c584.tar.gz gcc-998f1f73c2626f7ffa9655058e306b7f4e07c584.tar.bz2 |
Merge #1284
1284: Marklive: support arrayindex r=philberty a=thomasyonug
This makes `MarkLive` support `HIR::ArrayIndex` and adds a related test case.
Co-authored-by: Thomas Young <wenzhang5800@gmail.com>
Diffstat (limited to 'gcc')
-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()]; +} |