Mercurial > projects > ldc
annotate test/union5.d @ 100:5071469303d4 trunk
[svn r104] TONS OF FIXES.
Split up declaration, constant initializer gen and definition for globals, structs, classes and functions.
Improved ClassInfo support (not complete), not in vtable yet.
Fixed a bunch of forward reference problems.
Much more. Major commit! :)
author | lindquist |
---|---|
date | Fri, 16 Nov 2007 08:21:47 +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 } |