public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Marklive: support arrayindex
@ 2022-06-08 12:50 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:50 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b2fb51a2640b2529869542a305afba42cd83ff03
commit b2fb51a2640b2529869542a305afba42cd83ff03
Author: Thomas Young <wenzhang5800@gmail.com>
Date: Sun May 29 13:00:00 2022 +0800
Marklive: support arrayindex
Diff:
---
gcc/rust/lint/rust-lint-marklive.h | 6 ++++++
gcc/testsuite/rust/compile/torture/arrays_index3.rs | 15 +++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/gcc/rust/lint/rust-lint-marklive.h b/gcc/rust/lint/rust-lint-marklive.h
index 529afa63c2b..ef37e17c5fb 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 00000000000..8fa0a226d02
--- /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()];
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:50 [gcc/devel/rust/master] Marklive: support arrayindex Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).