public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] testing: try loop in const function
Date: Thu,  6 Oct 2022 20:05:38 +0000 (GMT)	[thread overview]
Message-ID: <20221006200538.3E6FD3947C29@sourceware.org> (raw)

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

                 reply	other threads:[~2022-10-06 20:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221006200538.3E6FD3947C29@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).