2 // The LLVM Compiler Infrastructure
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
11 * Created by Blaine Garst on 2/17/09.
15 // PURPOSE Test that variadic arguments compile and work for Blocks
21 int main(int argc
, char *argv
[]) {
23 long (^addthem
)(const char *, ...) = ^long (const char *format
, ...){
30 va_start(argp
, format
);
31 //printf("starting...\n");
32 for (p
= format
; *p
; p
++) switch (*p
) {
34 i
= va_arg(argp
, int);
35 //printf("i: %d\n", i);
39 d
= va_arg(argp
, double);
40 //printf("d: %g\n", d);
44 c
= va_arg(argp
, int);
45 //printf("c: '%c'\n", c);
49 //printf("...done\n\n");
52 long testresult
= addthem("ii", 10, 20);
53 if (testresult
!= 30) {
54 printf("got wrong result: %ld\n", testresult
);
57 testresult
= addthem("idc", 30, 40.0, 'a');
58 if (testresult
!= (70+'a')) {
59 printf("got different wrong result: %ld\n", testresult
);
62 printf("%s: Success\n", argv
[0]);