1 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple i386-pc-unknown
2 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9
3 // RUN: %clang_cc1 -fsyntax-only -fms-compatibility -DMS -verify %s -triple x86_64-pc-win32
9 __builtin_va_start(ap
, a
, a
); // expected-error {{too many arguments to function}}
10 __builtin_va_start(ap
, a
); // expected-error {{'va_start' used in function with fixed args}}
13 void f2(int a
, int b
, ...)
17 __builtin_va_start(ap
, 10); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
18 __builtin_va_start(ap
, a
); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
19 __builtin_va_start(ap
, b
);
22 void f3(float a
, ...) { // expected-note 2{{parameter of type 'float' is declared here}}
25 __builtin_va_start(ap
, a
); // expected-warning {{passing an object that undergoes default argument promotion to 'va_start' has undefined behavior}}
26 __builtin_va_start(ap
, (a
)); // expected-warning {{passing an object that undergoes default argument promotion to 'va_start' has undefined behavior}}
30 // stdarg: PR3075 and PR2531
31 void f4(const char *msg
, ...) {
33 __builtin_stdarg_start((ap
), (msg
));
34 __builtin_va_end (ap
);
39 __builtin_va_start(ap
,ap
); // expected-error {{'va_start' used in function with fixed args}}
44 __builtin_va_start(ap
); // expected-error {{too few arguments to function}}
49 foo(__builtin_va_list authors
, ...) {
50 __builtin_va_start (authors
, authors
);
51 (void)__builtin_va_arg(authors
, int);
52 __builtin_va_end (authors
);
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}}
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'}}
71 enum E
{ x
= -1, y
= 2, z
= 10000 };
72 void f9(__builtin_va_list args
)
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'}}
80 void f10(int a
, ...) {
83 i
= __builtin_va_start(ap
, a
); // expected-error {{assigning to 'int' from incompatible type 'void'}}
87 void f11(short s
, ...) { // expected-note {{parameter of type 'short' is declared here}}
89 __builtin_va_start(ap
, s
); // expected-warning {{passing an object that undergoes default argument promotion to 'va_start' has undefined behavior}}
93 void f12(register int i
, ...) { // expected-note {{parameter of type 'int' is declared here}}
95 __builtin_va_start(ap
, i
); // expected-warning {{passing a parameter declared with the 'register' keyword to 'va_start' has undefined behavior}}
99 enum __attribute__((packed
)) E1
{
103 void f13(enum E1 e
, ...) {
104 __builtin_va_list va
;
105 __builtin_va_start(va
, e
);
107 // In Microsoft compatibility mode, all enum types are int, but in
108 // non-ms-compatibility mode, this enumeration type will undergo default
109 // argument promotions.
110 // expected-note@-7 {{parameter of type 'enum E1' is declared here}}
111 // expected-warning@-6 {{passing an object that undergoes default argument promotion to 'va_start' has undefined behavior}}
113 __builtin_va_end(va
);
116 void f14(int e
, ...) {
117 // expected-error@+3 {{call to undeclared library function 'va_start'}}
118 // expected-note@+2 {{include the header <stdarg.h>}}
119 // expected-error@+1 {{too few arguments to function call}}
121 __builtin_va_list va
;