public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] testing: try loop in const function
@ 2022-10-06 20:05 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-10-06 20:05 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5a87f5f469bb214da2ace06c5a24775044c608fc

commit 5a87f5f469bb214da2ace06c5a24775044c608fc
Author: Faisal Abbas <faisal.abbas@elastica.co>
Date:   Mon Oct 3 19:32:30 2022 +0100

    testing: try loop in const function
    
    Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com>

Diff:
---
 gcc/testsuite/rust/compile/const9.rs | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

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;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-06 20:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06 20:05 [gcc/devel/rust/master] testing: try loop in const function 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).