Debian Codegraph @

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

raw
1
2 // https://issues.dlang.org/show_bug.cgi?id=16098
3
4 /*********************************************/
5
6 void testDynamicClosure()
7 {
8 byte a;
9 align(128) byte b;
10 assert((cast(size_t) &b) % 128 == 0);
11 b = 37;
12
13 byte foo() { return b; }
14 dg = &foo;
15 assert(dg() == 37);
16 }
17
18 __gshared byte delegate() dg;
19
20 /*********************************************/
21
22 void testStaticClosure()
23 {
24 byte aa;
25 align(128) byte b;
26 assert((cast(size_t) &b) % 128 == 0);
27 b = 73;
28
29 byte foo() { return b; }
30 assert(foo() == 73);
31 }
32
33 /*********************************************/
34
35 void test3()
36 {
37 struct S
38 {
39 align(32) int b;
40 }
41 }
42
43 /*********************************************/
44
45 align(16)
46 struct Cent
47 {
48 ulong lo; // low 64 bits
49 ulong hi; // high 64 bits
50 }
51
52 enum Cent One = { 1 };
53
54 Cent inc(Cent c) { return add(c, One); }
55
56 Cent add(Cent c1, Cent c2) { const Cent ret = { 3, 2 }; return ret; }
57
58 void test4()
59 {
60 const Cent C10_0 = { 0, 10 };
61 const Cent Cm10_0 = inc(C10_0);
62 }
63
64 /*********************************************/
65
66 int main()
67 {
68 testDynamicClosure();
69 testStaticClosure();
70 test3();
71 test4();
72 return 0;
73 }