Mercurial > projects > ldc
annotate test/union5.d @ 120:5ce8ab11e75a trunk
[svn r124] Fixed another D vararg + return in ptr bug.
Fixed some nested function calls failed to resolve the context ptr.
author | lindquist |
---|---|
date | Mon, 26 Nov 2007 07:26:21 +0100 |
parents | 9e1bd80a7e98 |
children |
rev | line source |
---|---|
76 | 1 module union5; |
2 | |
3 pragma(LLVM_internal, "notypeinfo") | |
4 { | |
5 union S | |
6 { | |
7 T t; | |
8 U u; | |
9 uint i; | |
10 struct { | |
11 ushort sl,sh; | |
12 } | |
13 } | |
14 | |
15 struct T | |
16 { | |
17 int i; | |
18 } | |
19 | |
20 struct U | |
21 { | |
22 float f; | |
23 } | |
24 } | |
25 | |
26 void main() | |
27 { | |
28 S s; | |
29 assert(s.t.i == 0); | |
30 assert(s.u.f == 0); | |
31 s.t.i = -1; | |
32 assert(s.i == 0xFFFF_FFFF); | |
33 float f = 3.1415; | |
34 s.u.f = f; | |
35 uint pi = *cast(uint*)&f; | |
36 assert(s.i == pi); | |
37 assert(s.sl == (pi&0xFFFF)); | |
38 assert(s.sh == (pi>>>16)); | |
39 } |