[committed,005/103] gccrs: testing: try loop in const function

Message ID 20230221120230.596966-6-arthur.cohen@embecosm.com
State Unresolved
Headers
Series [committed,001/103] gccrs: Fix missing dead code analysis ICE on local enum definition |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Arthur Cohen Feb. 21, 2023, noon UTC
  From: Faisal Abbas <faisal.abbas@elastica.co>

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 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/const9.rs
  

Patch

diff --git a/gcc/testsuite/rust/compile/const9.rs b/gcc/testsuite/rust/compile/const9.rs
new file mode 100644
index 00000000000..e71a62a33b1
--- /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;
+}