Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Sema / varargs-x86-64.c
blobf3164400d8479a64f493626c7bfe5e2de7285357
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9
3 void f1(void) {
4 const __builtin_va_list args2;
5 (void)__builtin_va_arg(args2, int); // expected-error {{first argument to 'va_arg' is of type 'const __builtin_va_list' and not 'va_list'}}
8 void f2(int a, ...) {
9 __builtin_ms_va_list ap;
10 __builtin_ms_va_start(ap, a); // expected-error {{'__builtin_ms_va_start' used in System V ABI function}}
13 void __attribute__((ms_abi)) g1(int a) {
14 __builtin_ms_va_list ap;
16 __builtin_ms_va_start(ap, a, a); // expected-error {{too many arguments to function}}
17 __builtin_ms_va_start(ap, a); // expected-error {{'va_start' used in function with fixed args}}
20 void __attribute__((ms_abi)) g2(int a, int b, ...) {
21 __builtin_ms_va_list ap;
23 __builtin_ms_va_start(ap, 10); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
24 __builtin_ms_va_start(ap, a); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
25 __builtin_ms_va_start(ap, b);
28 void __attribute__((ms_abi)) g3(float a, ...) { // expected-note 2{{parameter of type 'float' is declared here}}
29 __builtin_ms_va_list ap;
31 __builtin_ms_va_start(ap, a); // expected-warning {{passing an object that undergoes default argument promotion to 'va_start' has undefined behavior}}
32 __builtin_ms_va_start(ap, (a)); // expected-warning {{passing an object that undergoes default argument promotion to 'va_start' has undefined behavior}}
35 void __attribute__((ms_abi)) g5(void) {
36 __builtin_ms_va_list ap;
37 __builtin_ms_va_start(ap, ap); // expected-error {{'va_start' used in function with fixed args}}
40 void __attribute__((ms_abi)) g6(int a, ...) {
41 __builtin_ms_va_list ap;
42 __builtin_ms_va_start(ap); // expected-error {{too few arguments to function}}
45 void __attribute__((ms_abi))
46 bar(__builtin_ms_va_list authors, ...) {
47 __builtin_ms_va_start(authors, authors);
48 (void)__builtin_va_arg(authors, int);
49 __builtin_ms_va_end(authors);
52 void __attribute__((ms_abi)) g7(int a, ...) {
53 __builtin_ms_va_list ap;
54 __builtin_ms_va_start(ap, a);
55 // FIXME: This error message is sub-par.
56 __builtin_va_arg(ap, int) = 1; // expected-error {{expression is not assignable}}
57 int *x = &__builtin_va_arg(ap, int); // expected-error {{cannot take the address of an rvalue}}
58 __builtin_ms_va_end(ap);
61 void __attribute__((ms_abi)) g8(int a, ...) {
62 __builtin_ms_va_list ap;
63 __builtin_ms_va_start(ap, a);
64 (void)__builtin_va_arg(ap, void); // expected-error {{second argument to 'va_arg' is of incomplete type 'void'}}
65 __builtin_ms_va_end(ap);
68 enum E { x = -1, y = 2, z = 10000 };
69 void __attribute__((ms_abi)) g9(__builtin_ms_va_list args) {
70 (void)__builtin_va_arg(args, float); // expected-warning {{second argument to 'va_arg' is of promotable type 'float'}}
71 (void)__builtin_va_arg(args, enum E); // no-warning
72 (void)__builtin_va_arg(args, short); // expected-warning {{second argument to 'va_arg' is of promotable type 'short'}}
73 (void)__builtin_va_arg(args, char); // expected-warning {{second argument to 'va_arg' is of promotable type 'char'}}
76 void __attribute__((ms_abi)) g10(int a, ...) {
77 __builtin_va_list ap;
78 __builtin_va_start(ap, a); // expected-error {{'va_start' used in Win64 ABI function}}