2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10 * Created by Blaine Garst on 2/17/09.
14 // PURPOSE Test that variadic arguments compile and work for Blocks
20 int main(int argc
, char *argv
[]) {
22 long (^addthem
)(const char *, ...) = ^long (const char *format
, ...){
29 va_start(argp
, format
);
30 //printf("starting...\n");
31 for (p
= format
; *p
; p
++) switch (*p
) {
33 i
= va_arg(argp
, int);
34 //printf("i: %d\n", i);
38 d
= va_arg(argp
, double);
39 //printf("d: %g\n", d);
43 c
= va_arg(argp
, int);
44 //printf("c: '%c'\n", c);
48 //printf("...done\n\n");
51 long testresult
= addthem("ii", 10, 20);
52 if (testresult
!= 30) {
53 printf("got wrong result: %ld\n", testresult
);
56 testresult
= addthem("idc", 30, 40.0, 'a');
57 if (testresult
!= (70+'a')) {
58 printf("got different wrong result: %ld\n", testresult
);
61 printf("%s: Success\n", argv
[0]);