d: Merge upstream dmd, druntime 4ca4140e58, phobos 454dff14d.
[official-gcc.git] / gcc / testsuite / gdc.test / runnable / test16098.d
bloba5af2d564485fa0b112c9fcf53dbb034c2612ace
2 // https://issues.dlang.org/show_bug.cgi?id=16098
4 /*********************************************/
6 void testDynamicClosure()
8 byte a;
9 align(128) byte b;
10 assert((cast(size_t) &b) % 128 == 0);
11 b = 37;
13 byte foo() { return b; }
14 dg = &foo;
15 assert(dg() == 37);
18 __gshared byte delegate() dg;
20 /*********************************************/
22 void testStaticClosure()
24 byte aa;
25 align(128) byte b;
26 assert((cast(size_t) &b) % 128 == 0);
27 b = 73;
29 byte foo() { return b; }
30 assert(foo() == 73);
33 /*********************************************/
35 void test3()
37 struct S
39 align(32) int b;
43 /*********************************************/
45 align(16)
46 struct Cent
48 ulong lo; // low 64 bits
49 ulong hi; // high 64 bits
52 enum Cent One = { 1 };
54 Cent inc(Cent c) { return add(c, One); }
56 Cent add(Cent c1, Cent c2) { const Cent ret = { 3, 2 }; return ret; }
58 void test4()
60 const Cent C10_0 = { 0, 10 };
61 const Cent Cm10_0 = inc(C10_0);
64 /*********************************************/
66 int main()
68 testDynamicClosure();
69 testStaticClosure();
70 test3();
71 test4();
72 return 0;