[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / microsoft-varargs-diagnostics.cpp
blob0b76fdd92dabdb5c0c6950be2aea80617acc893c
1 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s -verify
3 extern "C" {
4 typedef char * va_list;
7 void test_no_arguments(int i, ...) {
8 __va_start(); // expected-error{{too few arguments to function call, expected at least 3, have 0}}
11 void test_one_argument(int i, ...) {
12 va_list ap;
13 __va_start(&ap); // expected-error{{too few arguments to function call, expected at least 3, have 1}}
16 void test_two_arguments(int i, ...) {
17 va_list ap;
18 __va_start(&ap, &i); // expected-error{{too few arguments to function call, expected at least 3, have 2}}
21 void test_non_last_argument(int i, int j, ...) {
22 va_list ap;
23 __va_start(&ap, &i, 4);
24 // expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}}
25 // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
28 void test_stack_allocated(int i, ...) {
29 va_list ap;
30 int j;
31 __va_start(&ap, &j, 4);
32 // expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}}
33 // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
36 void test_non_pointer_addressof(int i, ...) {
37 va_list ap;
38 __va_start(&ap, 1, 4);
39 // expected-error@-1{{passing 'int' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int' vs 'const char *')}}
40 // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}