diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-09-08 00:39:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-08 00:39:35 +0000 |
commit | f252b4093666cf1e3d948b22f00fc12bf283a83f (patch) | |
tree | 4f72d95d129fdfeffba1a160a0d5904e4ed59396 /gcc | |
parent | f03760b98ba4160f08ade309daf22fedaf1cc2dd (diff) | |
parent | 908f1e2022cd1b957a33187d921455ff86749065 (diff) | |
download | gcc-f252b4093666cf1e3d948b22f00fc12bf283a83f.zip gcc-f252b4093666cf1e3d948b22f00fc12bf283a83f.tar.gz gcc-f252b4093666cf1e3d948b22f00fc12bf283a83f.tar.bz2 |
Merge #1528
1528: add testcase with struct to test component_ref and constructor codes in eval_constant_expression() r=philberty a=abbasfaisal
Co-authored-by: Faisal Abbas <90.abbasfaisal@gmail.com>
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; +} + |