2 // RUN: %clang_cc1 -fsyntax-only -verify=c99 -std=c99 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify=c11 -std=c11 %s
4 // RUN: %clang_cc1 -fsyntax-only -verify=c23 -std=c23 %s
5 // RUN: %clang_cc1 -fsyntax-only -verify=c99-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c99 %s
6 // RUN: %clang_cc1 -fsyntax-only -verify=c11-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c11 %s
7 // RUN: %clang_cc1 -fsyntax-only -verify=c23-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c23 %s
9 struct astruct
{ char member
; };
11 ptrdiff_t p0
; // c99-error{{unknown type name 'ptrdiff_t'}} c11-error{{unknown type}} c23-error{{unknown type}} \
12 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
13 size_t s0
; // c99-error{{unknown type name 'size_t'}} c11-error{{unknown type}} c23-error{{unknown type}} \
14 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
15 rsize_t r0
; // c99-error{{unknown type name 'rsize_t'}} c11-error{{unknown type}} c23-error{{unknown type}} \
16 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
17 wchar_t wc0
; // c99-error{{unknown type name 'wchar_t'}} c11-error{{unknown type}} c23-error{{unknown type}} \
18 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
19 void *v0
= NULL
; // c99-error{{use of undeclared identifier 'NULL'}} c11-error{{undeclared identifier}} c23-error{{undeclared identifier}} \
20 c99
-modules
-error
{{undeclared identifier
}} c11
-modules
-error
{{undeclared identifier
}} c23
-modules
-error
{{undeclared identifier
}}
21 nullptr_t n0
; // c99-error{{unknown type name 'nullptr_t'}} c11-error{{unknown type}} c23-error{{unknown type}} \
22 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
23 static void f0(void) { unreachable(); } // c99-error{{call to undeclared function 'unreachable'}} c11-error{{undeclared function}} c23-error{{undeclared identifier}} \
24 c99
-modules
-error
{{undeclared function
}} c11
-modules
-error
{{undeclared function
}} c23
-modules
-error
{{undeclared identifier
}}
25 max_align_t m0
; // c99-error{{unknown type name 'max_align_t'}} c11-error{{unknown type}} c23-error{{unknown type}} \
26 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
27 size_t o0
= offsetof(struct astruct
, member
); // c99-error{{unknown type name 'size_t'}} c99-error{{call to undeclared function 'offsetof'}} c99-error{{expected expression}} c99-error{{use of undeclared identifier 'member'}} \
28 c11
-error
{{unknown type
}} c11
-error
{{undeclared function
}} c11
-error
{{expected expression
}} c11
-error
{{undeclared identifier
}} \
29 c23
-error
{{unknown type
}} c23
-error
{{undeclared identifier
}} c23
-error
{{expected expression
}} c23
-error
{{undeclared identifier
}} \
30 c99
-modules
-error
{{unknown type
}} c99
-modules
-error
{{undeclared function
}} c99
-modules
-error
{{expected expression
}} c99
-modules
-error
{{undeclared identifier
}} \
31 c11
-modules
-error
{{unknown type
}} c11
-modules
-error
{{undeclared function
}} c11
-modules
-error
{{expected expression
}} c11
-modules
-error
{{undeclared identifier
}} \
32 c23
-modules
-error
{{unknown type
}} c23
-modules
-error
{{undeclared identifier
}} c23
-modules
-error
{{expected expression
}} c23
-modules
-error
{{undeclared identifier
}}
33 wint_t wi0
; // c99-error{{unknown type name 'wint_t'}} c11-error{{unknown type}} c23-error{{unknown type}} \
34 c99
-modules
-error
{{unknown type name
'wint_t'}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
40 rsize_t r1
; // c99-error{{unknown type}} c11-error{{unknown type}} c23-error{{unknown type}} \
41 c99
-note@__stddef_size_t
.h
:*{{'size_t' declared here
}} c11
-note@__stddef_size_t
.h
:*{{'size_t' declared here
}} c23
-note@__stddef_size_t
.h
:*{{'size_t' declared here
}} \
42 c99
-modules
-error
{{'rsize_t' must be declared before it is used
}} c11
-modules
-error
{{must be declared
}} c23
-modules
-error
{{must be declared
}} \
43 c99
-modules
-note@__stddef_rsize_t
.h
:*{{declaration here is
not visible
}} c11
-modules
-note@__stddef_rsize_t
.h
:*{{declaration here is
not visible
}} c23
-modules
-note@__stddef_rsize_t
.h
:*{{declaration here is
not visible
}}
46 nullptr_t n1
; // c99-error{{unknown type}} c11-error{{unknown type}} \
47 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}}
48 static void f1(void) { unreachable(); } // c99-error{{undeclared function}} c11-error{{undeclared function}} \
49 c99
-modules
-error
{{undeclared function
}} c11
-modules
-error
{{undeclared function
}}
50 max_align_t m1
; // c99-error{{unknown type}} c99-modules-error{{'max_align_t' must be declared before it is used}} \
51 c99
-modules
-note@__stddef_max_align_t
.h
:*{{declaration here is
not visible
}}
52 size_t o1
= offsetof(struct astruct
, member
);
53 wint_t wi1
; // c99-error{{unknown type}} c11-error{{unknown type}} c23-error{{unknown type}} \
54 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
56 // rsize_t needs to be opted into via __STDC_WANT_LIB_EXT1__ >= 1.
57 #define __STDC_WANT_LIB_EXT1__ 1
64 nullptr_t n2
; // c99-error{{unknown type}} c11-error{{unknown type}} \
65 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}}
66 static void f2(void) { unreachable(); } // c99-error{{undeclared function}} c11-error{{undeclared function}} \
67 c99
-modules
-error
{{undeclared function
}} c11
-modules
-error
{{undeclared function
}}
68 max_align_t m2
; // c99-error{{unknown type}}
69 size_t o2
= offsetof(struct astruct
, member
);
70 wint_t wi2
; // c99-error{{unknown type}} c11-error{{unknown type}} c23-error{{unknown type}} \
71 c99
-modules
-error
{{unknown type
}} c11
-modules
-error
{{unknown type
}} c23
-modules
-error
{{unknown type
}}
73 // m2 and wi2 don't generate errors in modules, the "must be declared before used"
74 // errors are only emitted the first time the known-but-not-visible type is seen.