aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorFaisal Abbas <faisal.abbas@elastica.co>2022-10-03 19:32:30 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2023-02-21 12:36:32 +0100
commitd072b4a5164e1a1b5db06a7a6213c6182550cd94 (patch)
tree6197a450043430913bf818ea1078596257f1f641 /gcc
parent543ba35905b948a6cd0cf39832a020597068570d (diff)
downloadgcc-d072b4a5164e1a1b5db06a7a6213c6182550cd94.zip
gcc-d072b4a5164e1a1b5db06a7a6213c6182550cd94.tar.gz
gcc-d072b4a5164e1a1b5db06a7a6213c6182550cd94.tar.bz2
gccrs: testing: try loop in const function
Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com> gcc/testsuite/ChangeLog: * rust/compile/const9.rs: New test. Signed-off-by: Faisal Abbas <faisal.abbas@elastica.co>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/rust/compile/const9.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/const9.rs b/gcc/testsuite/rust/compile/const9.rs
new file mode 100644
index 0000000..e71a62a
--- /dev/null
+++ b/gcc/testsuite/rust/compile/const9.rs
@@ -0,0 +1,18 @@
+// { dg-options "-w -O0 -fdump-tree-gimple" }
+const fn test(mut x: i32) -> i32 {
+ loop {
+ if x == 10 {
+ break;
+ }
+
+ x = x + 1;
+ }
+ return x;
+}
+
+const X: i32 = test(0);
+
+fn main() {
+ // { dg-final { scan-tree-dump-times {x = 10} 1 gimple } }
+ let x = X;
+}