Mercurial > projects > ldc
annotate test/vararg4.d @ 339:385a18242485 trunk
[svn r360] Another mostly rewrite of DtoArrayInit. Should be much more robust now, and probably faster code generated for the most common cases too!
Fixed issues with slice initialization (!!!) of multidimensional static arrays.
Attempt to fix issue with referencing nested 'this' pointers introduced in DMD 1.033 merge.
author | lindquist |
---|---|
date | Sun, 13 Jul 2008 01:29:49 +0200 |
parents | 895e1b50cf2a |
children |
rev | line source |
---|---|
70
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
1 module vararg4; |
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
70
diff
changeset
|
2 import tango.core.Vararg; |
295
895e1b50cf2a
[svn r316] Fixed array slice assignments like: int[] arr = ...; arr[] = 42;
lindquist
parents:
270
diff
changeset
|
3 extern(C) int printf(char*, ...); |
70
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
4 |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
5 void vafunc(...) |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
6 { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
7 foreach(i,v; _arguments) { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
8 if (typeid(byte) == v) { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
9 printf("byte(%d)\n", va_arg!(byte)(_argptr)); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
10 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
11 else if (typeid(short) == v) { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
12 printf("short(%d)\n", va_arg!(short)(_argptr)); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
13 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
14 else if (typeid(int) == v) { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
15 printf("int(%d)\n", va_arg!(int)(_argptr)); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
16 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
17 else if (typeid(long) == v) { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
18 printf("long(%ld)\n", va_arg!(long)(_argptr)); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
19 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
20 else if (typeid(float) == v) { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
21 printf("float(%f)\n", va_arg!(float)(_argptr)); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
22 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
23 else if (typeid(double) == v) { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
24 printf("double(%f)\n", va_arg!(double)(_argptr)); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
25 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
26 else if (typeid(real) == v) { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
27 printf("real(%f)\n", va_arg!(real)(_argptr)); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
28 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
29 else |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
30 assert(0, "unsupported type"); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
31 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
32 } |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
33 |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
34 void main() |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
35 { |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
36 vafunc(byte.max,short.max,1,2,3,4L,5.0f,6.0,cast(real)7); |
fb265a6efea1
[svn r74] Fixed passing types with different alignment to D-style variadic functions.
lindquist
parents:
diff
changeset
|
37 } |