1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9 3 4 void f1(int a) 5 { 6 __builtin_va_list ap; 7 8 __builtin_va_start(ap, a, a); // expected-error {{too many arguments to function}} 9 __builtin_va_start(ap, a); // expected-error {{'va_start' used in function with fixed args}} 10 } 11 12 void f2(int a, int b, ...) 13 { 14 __builtin_va_list ap; 15 16 __builtin_va_start(ap, 10); // expected-warning {{second parameter of 'va_start' not last named argument}} 17 __builtin_va_start(ap, a); // expected-warning {{second parameter of 'va_start' not last named argument}} 18 __builtin_va_start(ap, b); 19 } 20 21 void f3(float a, ...) 22 { 23 __builtin_va_list ap; 24 25 __builtin_va_start(ap, a); 26 __builtin_va_start(ap, (a)); 27 } 28 29 30 // stdarg: PR3075 31 void f4(const char *msg, ...) { 32 __builtin_va_list ap; 33 __builtin_stdarg_start((ap), (msg)); 34 __builtin_va_end (ap); 35 } 36 37 void f5() { 38 __builtin_va_list ap; 39 __builtin_va_start(ap,ap); // expected-error {{'va_start' used in function with fixed args}} 40 } 41 42 void f6(int a, ...) { 43 __builtin_va_list ap; 44 __builtin_va_start(ap); // expected-error {{too few arguments to function}} 45 } 46 47 // PR3350 48 void 49 foo(__builtin_va_list authors, ...) { 50 __builtin_va_start (authors, authors); 51 (void)__builtin_va_arg(authors, int); 52 __builtin_va_end (authors); 53 } 54 55 void f7(int a, ...) { 56 __builtin_va_list ap; 57 __builtin_va_start(ap, a); 58 // FIXME: This error message is sub-par. 59 __builtin_va_arg(ap, int) = 1; // expected-error {{expression is not assignable}} 60 int *x = &__builtin_va_arg(ap, int); // expected-error {{cannot take the address of an rvalue}} 61 __builtin_va_end(ap); 62 } 63 64 void f8(int a, ...) { 65 __builtin_va_list ap; 66 __builtin_va_start(ap, a); 67 (void)__builtin_va_arg(ap, void); // expected-error {{second argument to 'va_arg' is of incomplete type 'void'}} 68 __builtin_va_end(ap); 69 } 70 71 enum E { x = -1, y = 2, z = 10000 }; 72 void f9(__builtin_va_list args) 73 { 74 (void)__builtin_va_arg(args, float); // expected-warning {{second argument to 'va_arg' is of promotable type 'float'}} 75 (void)__builtin_va_arg(args, enum E); // Don't warn here in C 76 (void)__builtin_va_arg(args, short); // expected-warning {{second argument to 'va_arg' is of promotable type 'short'}} 77 (void)__builtin_va_arg(args, char); // expected-warning {{second argument to 'va_arg' is of promotable type 'char'}} 78 } 79