From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id EF8EE385022A; Mon, 12 Sep 2022 07:20:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EF8EE385022A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662967258; bh=//5nhIfP91QQaglGJzgM78yz70EwjORUGXUeoYJIqMo=; h=From:To:Subject:Date:From; b=c1qtKERhhHBmk+3IUgFLkufMQThH0unEZvHBcxp0jmfVFc4/AofIl9tqWu0otmIKv TRXZ8q7ibPNpy7GCW+hoJYiwB9fSLTq/LiDtDUKcOxujR125MXdMm4LhnGkQOHBfKS Wmg+HTjevbn62HVyAJ2NpqvSE9fj2k6xTQ1svesc= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] testsuite: add loop condition execution test X-Act-Checkin: gcc X-Git-Author: liushuyu X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: bed01725c1c6a7a463a9b42082ef91a5406588ec X-Git-Newrev: 6839ad40eebf982f149452cc294ab387350abcef Message-Id: <20220912072058.EF8EE385022A@sourceware.org> Date: Mon, 12 Sep 2022 07:20:58 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6839ad40eebf982f149452cc294ab387350abcef commit 6839ad40eebf982f149452cc294ab387350abcef Author: liushuyu Date: Tue Sep 6 22:41:17 2022 -0600 testsuite: add loop condition execution test Diff: --- .../rust/execute/torture/loop-condition-eval.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gcc/testsuite/rust/execute/torture/loop-condition-eval.rs b/gcc/testsuite/rust/execute/torture/loop-condition-eval.rs new file mode 100644 index 00000000000..008965917ab --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/loop-condition-eval.rs @@ -0,0 +1,21 @@ +// { dg-output "1\n" } +pub fn test() -> u64 { + let mut n = 113383; // #20 in https://oeis.org/A006884 + while n != 1 { + n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; + } + n +} + +pub fn test_1() -> u64 { + test() +} + +extern "C" { + fn printf(fmt: *const i8, ...); +} + +fn main() -> i32 { + unsafe { printf("%lu\n" as *const str as *const i8, test_1()) } + 0 +}