xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/microsoft-varargs-diagnostics.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s -verify
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc extern "C" {
4*0a6a1f1dSLionel Sambuc typedef char * va_list;
5*0a6a1f1dSLionel Sambuc }
6*0a6a1f1dSLionel Sambuc 
test_no_arguments(int i,...)7*0a6a1f1dSLionel Sambuc void test_no_arguments(int i, ...) {
8*0a6a1f1dSLionel Sambuc   __va_start(); // expected-error{{too few arguments to function call, expected at least 3, have 0}}
9*0a6a1f1dSLionel Sambuc }
10*0a6a1f1dSLionel Sambuc 
test_one_argument(int i,...)11*0a6a1f1dSLionel Sambuc void test_one_argument(int i, ...) {
12*0a6a1f1dSLionel Sambuc   va_list ap;
13*0a6a1f1dSLionel Sambuc   __va_start(&ap); // expected-error{{too few arguments to function call, expected at least 3, have 1}}
14*0a6a1f1dSLionel Sambuc }
15*0a6a1f1dSLionel Sambuc 
test_two_arguments(int i,...)16*0a6a1f1dSLionel Sambuc void test_two_arguments(int i, ...) {
17*0a6a1f1dSLionel Sambuc   va_list ap;
18*0a6a1f1dSLionel Sambuc   __va_start(&ap, &i); // expected-error{{too few arguments to function call, expected at least 3, have 2}}
19*0a6a1f1dSLionel Sambuc }
20*0a6a1f1dSLionel Sambuc 
test_non_last_argument(int i,int j,...)21*0a6a1f1dSLionel Sambuc void test_non_last_argument(int i, int j, ...) {
22*0a6a1f1dSLionel Sambuc   va_list ap;
23*0a6a1f1dSLionel Sambuc   __va_start(&ap, &i, 4);
24*0a6a1f1dSLionel Sambuc   // expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}}
25*0a6a1f1dSLionel Sambuc   // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
26*0a6a1f1dSLionel Sambuc }
27*0a6a1f1dSLionel Sambuc 
test_stack_allocated(int i,...)28*0a6a1f1dSLionel Sambuc void test_stack_allocated(int i, ...) {
29*0a6a1f1dSLionel Sambuc   va_list ap;
30*0a6a1f1dSLionel Sambuc   int j;
31*0a6a1f1dSLionel Sambuc   __va_start(&ap, &j, 4);
32*0a6a1f1dSLionel Sambuc   // expected-error@-1{{passing 'int *' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int *' vs 'const char *')}}
33*0a6a1f1dSLionel Sambuc   // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
34*0a6a1f1dSLionel Sambuc }
35*0a6a1f1dSLionel Sambuc 
test_non_pointer_addressof(int i,...)36*0a6a1f1dSLionel Sambuc void test_non_pointer_addressof(int i, ...) {
37*0a6a1f1dSLionel Sambuc   va_list ap;
38*0a6a1f1dSLionel Sambuc   __va_start(&ap, 1, 4);
39*0a6a1f1dSLionel Sambuc   // expected-error@-1{{passing 'int' to parameter of incompatible type 'const char *': type mismatch at 2nd parameter ('int' vs 'const char *')}}
40*0a6a1f1dSLionel Sambuc   // expected-error@-2{{passing 'int' to parameter of incompatible type 'unsigned int': type mismatch at 3rd parameter ('int' vs 'unsigned int')}}
41*0a6a1f1dSLionel Sambuc }
42*0a6a1f1dSLionel Sambuc 
43