1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
// RUN: rm -fR %t
// RUN: split-file %s %t
// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds0.c
// RUN: %clang_cc1 -fsyntax-only -verify=expected-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=implicit-function-declaration -std=c89 %t/stdargneeds0.c
// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds1.c
// RUN: %clang_cc1 -fsyntax-only -verify=expected-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=implicit-function-declaration -std=c89 %t/stdargneeds1.c
// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds2.c
// RUN: %clang_cc1 -fsyntax-only -verify=expected-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=implicit-function-declaration -std=c89 %t/stdargneeds2.c
// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds3.c
// RUN: %clang_cc1 -fsyntax-only -verify=expected-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=implicit-function-declaration -std=c89 %t/stdargneeds3.c
// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds4.c
// RUN: %clang_cc1 -fsyntax-only -verify=expected-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=implicit-function-declaration -std=c89 %t/stdargneeds4.c
// RUN: %clang_cc1 -fsyntax-only -verify -Werror=implicit-function-declaration -std=c89 %t/stdargneeds5.c
// RUN: %clang_cc1 -fsyntax-only -verify=expected-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=implicit-function-declaration -std=c89 %t/stdargneeds5.c
// Split the file so that the "implicitly declaring library function" errors get repeated.
// Use C89 to verify that __need_ can be used to get types that wouldn't normally be available.
//--- stdargneeds0.c
static void f(int p, ...) {
__gnuc_va_list g; // expected-error{{undeclared identifier '__gnuc_va_list'}} expected-modules-error{{undeclared identifier}}
va_list v; // expected-error{{undeclared identifier 'va_list'}} expected-modules-error{{undeclared identifier}}
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'}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}} expected-modules-error{{undeclared identifier}}
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'}} \
expected-modules-error{{implicit declaration of function}} expected-modules-error{{expected expression}} expected-modules-error{{undeclared identifier}}
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'}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}} expected-modules-error{{undeclared identifier}}
__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'}} \
expected-modules-error{{implicit declaration of function}} expected-modules-error{{undeclared identifier}} expected-modules-error{{undeclared identifier}}
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'}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}} expected-modules-error{{undeclared identifier}} expected-modules-error{{undeclared identifier}}
}
//--- stdargneeds1.c
#define __need___va_list
#include <stdarg.h>
static void f(int p, ...) {
__gnuc_va_list g;
va_list v; // expected-error{{undeclared identifier}} \
expected-modules-error{{'va_list' must be declared before it is used}} expected-modules-note@__stdarg_va_list.h:*{{declaration here is not visible}}
va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicit declaration of function}} expected-modules-error{{expected expression}}
va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
__va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicit declaration of function}}
va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
}
//--- stdargneeds2.c
#define __need_va_list
#include <stdarg.h>
static void f(int p, ...) {
__gnuc_va_list g; // expected-error{{undeclared identifier}} \
expected-modules-error{{'__gnuc_va_list' must be declared before it is used}} expected-modules-note@__stdarg___gnuc_va_list.h:*{{declaration here is not visible}}
va_list v;
va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} \
expected-modules-error{{implicit declaration of function}} expected-modules-error{{expected expression}}
va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
__va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicit declaration of function}}
va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
}
//--- stdargneeds3.c
#define __need_va_list
#define __need_va_arg
#include <stdarg.h>
static void f(int p, ...) {
__gnuc_va_list g; // expected-error{{undeclared identifier}} \
expected-modules-error{{'__gnuc_va_list' must be declared before it is used}} expected-modules-note@__stdarg___gnuc_va_list.h:*{{declaration here is not visible}}
va_list v;
va_start(v, p);
int i = va_arg(v, int);
va_end(v);
__va_copy(g, v); // expected-error{{implicit declaration of function}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicit declaration of function}}
va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} expected-error{{undeclared identifier}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
}
//--- stdargneeds4.c
#define __need___va_list
#define __need_va_list
#define __need___va_copy
#include <stdarg.h>
static void f(int p, ...) {
__gnuc_va_list g;
va_list v;
va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} \
expected-modules-error{{implicit declaration of function}} expected-modules-error{{expected expression}}
va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
__va_copy(g, v);
va_copy(g, v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
}
//--- stdargneeds5.c
#define __need___va_list
#define __need_va_list
#define __need_va_copy
#include <stdarg.h>
static void f(int p, ...) {
__gnuc_va_list g;
va_list v;
va_start(v, p); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
int i = va_arg(v, int); // expected-error{{implicit declaration of function}} expected-error{{expected expression}} \
expected-modules-error{{implicit declaration of function}} expected-modules-error{{expected expression}}
va_end(v); // expected-error{{implicitly declaring library function}} expected-note{{provide a declaration}} \
expected-modules-error{{implicitly declaring library function}} expected-modules-note{{provide a declaration}}
__va_copy(g, v); // expected-error{{implicit declaration of function}} expected-modules-error{{implicit declaration of function}}
va_copy(g, v);
}
|