From: Faisal Abbas Date: Mon, 3 Oct 2022 18:32:30 +0000 (+0100) Subject: gccrs: testing: try loop in const function X-Git-Tag: basepoints/gcc-14~1049 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d072b4a5164e1a1b5db06a7a6213c6182550cd94;p=thirdparty%2Fgcc.git gccrs: testing: try loop in const function Signed-off-by: Faisal Abbas <90.abbasfaisal@gmail.com> gcc/testsuite/ChangeLog: * rust/compile/const9.rs: New test. Signed-off-by: Faisal Abbas --- diff --git a/gcc/testsuite/rust/compile/const9.rs b/gcc/testsuite/rust/compile/const9.rs new file mode 100644 index 000000000000..e71a62a33b1e --- /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; +}