Debian Codegraph @

gcc/testsuite/gdc.test/runnable/b16360.d

raw
1 // REQUIRED_ARGS: -inline
2
3 pragma(inline, true)
4 auto foo()
5 {
6 static struct U
7 {
8 int a = 42;
9 float b;
10 }
11 U u;
12 return u.a;
13 }
14
15 pragma(inline, true)
16 T bitCast(T, S)(auto ref S s)
17 {
18 union BitCaster
19 {
20 S ss;
21 T tt;
22 }
23 BitCaster bt;
24 bt.ss = s;
25 return bt.tt;
26 }
27
28 pragma(inline, true)
29 int withFuncCalls()
30 {
31 static struct WithFuncCalls
32 {
33 int v;
34 pragma(inline, true)
35 int call(){return v;}
36 pragma(inline, true)
37 void otherCall(){v++;}
38 }
39 auto bt = WithFuncCalls(50);
40 bt.v += -9;
41 bt.otherCall();
42 return bt.call();
43 }
44
45 void main()
46 {
47 assert(foo == 42);
48 assert(bitCast!int(1.0f) == 0x3f800000);
49 assert(withFuncCalls() == 42);
50 }