diff options
author | Faisal Abbas <90.abbasfaisal@gmail.com> | 2022-09-06 22:24:52 +0100 |
---|---|---|
committer | Faisal Abbas <90.abbasfaisal@gmail.com> | 2022-09-06 22:27:59 +0100 |
commit | 908f1e2022cd1b957a33187d921455ff86749065 (patch) | |
tree | e8dadb22949c5acaec1bc1bd78924cba99f4cda3 /gcc | |
parent | a876e9e8f0c48b476116b0f5808ab32dfb520f56 (diff) | |
download | gcc-908f1e2022cd1b957a33187d921455ff86749065.zip gcc-908f1e2022cd1b957a33187d921455ff86749065.tar.gz gcc-908f1e2022cd1b957a33187d921455ff86749065.tar.bz2 |
add testcase with struct to test component_ref and constructor codes in
eval_constant_expression()
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/rust/compile/const8.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/const8.rs b/gcc/testsuite/rust/compile/const8.rs new file mode 100644 index 0000000..94c4268 --- /dev/null +++ b/gcc/testsuite/rust/compile/const8.rs @@ -0,0 +1,40 @@ +// { dg-options "-w -O0 -fdump-tree-gimple" } +struct Foo { + First: i32, + Second: f32 +} + +struct Bar { + First: i32, + Second: f32 +} + +struct Baz { + First: i32, + Second: f32 +} +const A:Foo = Foo { First: 1, Second: 1.0 }; +const B:Bar = Bar { First: 2, Second: 2.0 }; +const C:Baz = Baz { First: 3, Second: 2.0 }; + +const fn test() -> f32 { + if (A.First == 2) { + return A.Second; + } + else if (B.First == 2) { + return B.Second; + } + else if (C.First == 2) { + return C.Second; + } + + return 0.0; +} + +const D:f32 = test(); + +fn main() { + // { dg-final { scan-tree-dump-times {d = 2.0} 1 gimple } } + let d = D; +} + |