1 // RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks 2 // expected-no-diagnostics 3 4 #include <stdarg.h> 5 6 int main(int argc, char *argv[]) { 7 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; 29 } 30 return result; 31 }; 32 long testresult = addthem("ii", 10, 20); 33 if (testresult != 30) { 34 return 1; 35 } 36 testresult = addthem("idc", 30, 40.0, 'a'); 37 if (testresult != (70+'a')) { 38 return 1; 39 } 40 return 0; 41 } 42 43