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