diff options
author | liushuyu <liushuyu011@gmail.com> | 2022-09-06 22:41:17 -0600 |
---|---|---|
committer | liushuyu <liushuyu011@gmail.com> | 2022-09-06 22:41:17 -0600 |
commit | 6839ad40eebf982f149452cc294ab387350abcef (patch) | |
tree | 9ddcf544de1b049b32b7511d6f18c01a12ceaa8d /gcc | |
parent | bed01725c1c6a7a463a9b42082ef91a5406588ec (diff) | |
download | gcc-6839ad40eebf982f149452cc294ab387350abcef.zip gcc-6839ad40eebf982f149452cc294ab387350abcef.tar.gz gcc-6839ad40eebf982f149452cc294ab387350abcef.tar.bz2 |
testsuite: add loop condition execution test
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/rust/execute/torture/loop-condition-eval.rs | 21 |
1 files changed, 21 insertions, 0 deletions
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 0000000..0089659 --- /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 +} |