[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / variadic-block.c
blob4f23cb8e0814e39dd16b122f88e577b4b383a629
1 // RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks
2 // expected-no-diagnostics
4 #include <stdarg.h>
6 int main(int argc, char *argv[]) {
8 long (^addthem)(const char *, ...) = ^long (const char *format, ...){
9 va_list argp;
10 const char *p;
11 int i;
12 char c;
13 double d;
14 long result = 0;
15 va_start(argp, format);
16 for (p = format; *p; p++) switch (*p) {
17 case 'i':
18 i = va_arg(argp, int);
19 result += i;
20 break;
21 case 'd':
22 d = va_arg(argp, double);
23 result += (int)d;
24 break;
25 case 'c':
26 c = va_arg(argp, int);
27 result += c;
28 break;
30 return result;
32 long testresult = addthem("ii", 10, 20);
33 if (testresult != 30) {
34 return 1;
36 testresult = addthem("idc", 30, 40.0, 'a');
37 if (testresult != (70+'a')) {
38 return 1;
40 return 0;