]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: testing: try loop in const function
authorFaisal Abbas <faisal.abbas@elastica.co>
Mon, 3 Oct 2022 18:32:30 +0000 (19:32 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 21 Feb 2023 11:36:32 +0000 (12:36 +0100)
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>
gcc/testsuite/rust/compile/const9.rs [new file with mode: 0644]

diff --git a/gcc/testsuite/rust/compile/const9.rs b/gcc/testsuite/rust/compile/const9.rs
new file mode 100644 (file)
index 0000000..e71a62a
--- /dev/null
@@ -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;
+}