Mercurial > projects > ldc
annotate tests/mini/vararg4.d @ 1602:a413ae7329bf
Merge DMD r243: some harmonization with D2 dmd
---
dmd/aggregate.h | 24 ++++-
dmd/attrib.c | 63 ++++++----
dmd/attrib.h | 10 +-
dmd/declaration.h | 5 +-
dmd/func.c | 337 ++++++++++++++++++++++-------------------------------
dmd/mars.c | 2 +-
dmd/mars.h | 7 +
dmd/mtype.h | 13 ++-
dmd/parse.c | 32 ++++-
dmd/parse.h | 14 ++-
dmd/scope.h | 2 +-
11 files changed, 263 insertions(+), 246 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:19 -0300 |
parents | 1bb99290e03a |
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 } |