|
| 1 | +// RUN: split-file %s %t |
| 2 | +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds0.c |
| 3 | +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds1.c |
| 4 | +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds2.c |
| 5 | +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds3.c |
| 6 | +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds4.c |
| 7 | +// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds5.c |
| 8 | + |
| 9 | +// Split the file so that the "implicitly declaring library function" errors get repeated. |
| 10 | +// Use C89 to verify that __need_ can be used to get types that wouldn't normally be available. |
| 11 | + |
| 12 | +//--- stdargneeds0.c |
| 13 | +static void f(int p, ...) { |
| 14 | + __gnuc_va_list g; // expected-error{{undeclared identifier '__gnuc_va_list'}} |
| 15 | + va_list v; // expected-error{{undeclared identifier 'va_list'}} |
| 16 | + va_start(v, p); // expected-error{{implicitly declaring library function 'va_start'}} expected-note{{include the header <stdarg.h> or explicitly provide a declaration for 'va_start'}} expected-error{{undeclared identifier 'v'}} |
| 17 | + int i = va_arg(v, int); // expected-error{{implicit declaration of function 'va_arg'}} expected-error{{expected expression}} expected-error{{use of undeclared identifier 'v'}} |
| 18 | + va_end(v); // expected-error{{implicitly declaring library function 'va_end'}} expected-note{{include the header <stdarg.h> or explicitly provide a declaration for 'va_end'}} expected-error{{undeclared identifier 'v'}} |
| 19 | + __va_copy(g, v); // expected-error{{implicit declaration of function '__va_copy'}} expected-error{{use of undeclared identifier 'g'}} expected-error{{use of undeclared identifier 'v'}} |
| 20 | + va_copy(g, v); // expected-error{{implicitly declaring library function 'va_copy'}} expected-note{{include the header <stdarg.h> or explicitly provide a declaration for 'va_copy'}} expected-error{{use of undeclared identifier 'g'}} expected-error{{use of undeclared identifier 'v'}} |
| 21 | +} |
| 22 | + |
| 23 | +//--- stdargneeds1.c |
| 24 | +#define __need___va_list |
| 25 | +#include <stdarg.h> |
| 26 | +static void f(int p, ...) { |
| 27 | + __gnuc_va_list g; |
| 28 | + va_list v; // expected-error{{undeclared identifier}} |
| 29 | + va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} |
| 30 | + int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} expected-error{{undeclared identifier}} |
| 31 | + va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} |
| 32 | + __va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}} |
| 33 | + va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} |
| 34 | +} |
| 35 | + |
| 36 | +//--- stdargneeds2.c |
| 37 | +#define __need_va_list |
| 38 | +#include <stdarg.h> |
| 39 | +static void f(int p, ...) { |
| 40 | + __gnuc_va_list g; // expected-error{{undeclared identifier}} |
| 41 | + va_list v; |
| 42 | + va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} |
| 43 | + int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} |
| 44 | + va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} |
| 45 | + __va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}} |
| 46 | + va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} |
| 47 | +} |
| 48 | + |
| 49 | +//--- stdargneeds3.c |
| 50 | +#define __need_va_list |
| 51 | +#define __need_va_arg |
| 52 | +#include <stdarg.h> |
| 53 | +static void f(int p, ...) { |
| 54 | + __gnuc_va_list g; // expected-error{{undeclared identifier}} |
| 55 | + va_list v; |
| 56 | + va_start(v, p); |
| 57 | + int i = va_arg(v, int); |
| 58 | + va_end(v); |
| 59 | + __va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}} |
| 60 | + va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} |
| 61 | +} |
| 62 | + |
| 63 | +//--- stdargneeds4.c |
| 64 | +#define __need___va_list |
| 65 | +#define __need_va_list |
| 66 | +#define __need___va_copy |
| 67 | +#include <stdarg.h> |
| 68 | +static void f(int p, ...) { |
| 69 | + __gnuc_va_list g; |
| 70 | + va_list v; |
| 71 | + va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} |
| 72 | + int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} |
| 73 | + va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} |
| 74 | + __va_copy(g, v); |
| 75 | + va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} |
| 76 | +} |
| 77 | + |
| 78 | +//--- stdargneeds5.c |
| 79 | +#define __need___va_list |
| 80 | +#define __need_va_list |
| 81 | +#define __need_va_copy |
| 82 | +#include <stdarg.h> |
| 83 | +static void f(int p, ...) { |
| 84 | + __gnuc_va_list g; |
| 85 | + va_list v; |
| 86 | + va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} |
| 87 | + int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} |
| 88 | + va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} |
| 89 | + __va_copy(g, v); // expected-error{{implicit declaration of function}} |
| 90 | + va_copy(g, v); |
| 91 | +} |
0 commit comments