You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang][modules] giving the __stddef_ headers their own modules can cause redeclaration errors with -fbuiltin-headers-in-system-modules
On Apple platforms, some of the stddef.h types are also declared in system headers. In particular NULL has a conflicting declaration in <sys/_types/_null.h>. When that's in a different module from <__stddef_null.h>, redeclaration errors can occur.
Make the __stddef_ headers be non-modular in -fbuiltin-headers-in-system-modules and restore them back to not respecting their header guards. Still define the header guards though. __stddef_max_align_t.h was in _Builtin_stddef_max_align_t prior to the addition of _Builtin_stddef, and it needs to stay in a module because struct's can't be type merged. __stddef_wint_t.h didn't used to have a module, but leave it in it current module since it doesn't really belong to stddef.h.
// size_t is declared in both size_t.h and __stddef_size_t.h, both of which are
11
-
// modular headers. Regardless of whether stddef.h joins the StdDef test module
12
-
// or is in its _Builtin_stddef module, __stddef_size_t.h will be in
13
-
// _Builtin_stddef.size_t. It's not defined which module will win as the expected
14
-
// provider of size_t. For the purposes of this test it doesn't matter which header
15
-
// gets reported, just as long as it isn't other.h or include_again.h.
16
-
size_tst; // expected-error-re {{missing '#include "{{size_t|__stddef_size_t}}.h"'; 'size_t' must be declared before it is used}}
17
-
// expected-note@size_t.h:* 0+ {{here}}
18
-
// expected-note@__stddef_size_t.h:* 0+ {{here}}
10
+
// size_t is declared in both size_t.h and __stddef_size_t.h. If
11
+
// -fbuiltin-headers-in-system-modules is set, then __stddef_size_t.h is a
12
+
// non-modular header that will be transitively pulled in the StdDef test module
13
+
// by include_again.h. Otherwise it will be in the _Builtin_stddef module. In
14
+
// any case it's not defined which module will win as the expected provider of
15
+
// size_t. For the purposes of this test it doesn't matter which of the two
16
+
// providing headers get reported.
17
+
size_tst; // builtin-headers-in-system-modules-error-re {{missing '#include "{{size_t|include_again}}.h"'; 'size_t' must be declared before it is used}} \
18
+
no-builtin-headers-in-system-modules-error-re {{missing '#include "{{size_t|__stddef_size_t}}.h"'; 'size_t' must be declared before it is used}}
0 commit comments