annotate tests/mini/union5.d @ 979:523bf4f166bc

Fix some assembler issues: The assembler was miscompiling "add" (specifically, the "add reg/mem, imm" variations). The change that caused this seems to have been made because without it, some "add"s didn't compile at all. This patch reverts the previous change, and makes sure assembler operands are remapped correctly even though the input operands auto-generated due to updating operations aren't explicitly used.
author Frits van Bommel <fvbommel wxs.nl>
date Wed, 18 Feb 2009 21:46:14 +0100
parents 44f08170f4ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
1 module union5;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
2
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
3 union S
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
4 {
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
5 T t;
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
6 U u;
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
7 uint i;
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
8 struct {
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
9 ushort sl,sh;
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
10 }
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
11 }
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
12
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
13 struct T
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
14 {
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
15 int i;
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
16 }
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
17
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
18 struct U
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
19 {
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
20 float f;
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
21 }
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
22
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
23 void main()
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
24 {
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
25 S s;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
26 assert(s.t.i == 0);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
27 assert(s.u.f == 0);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
28 s.t.i = -1;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
29 assert(s.i == 0xFFFF_FFFF);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
30 float f = 3.1415;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
31 s.u.f = f;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
32 uint pi = *cast(uint*)&f;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
33 assert(s.i == pi);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
34 assert(s.sl == (pi&0xFFFF));
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
35 assert(s.sh == (pi>>>16));
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
36 }