[PATCH] D157757: [Headers] Replace __need_STDDEF_H_misc with specific __need_ macros

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 15 05:16:07 PDT 2023


aaron.ballman accepted this revision.
aaron.ballman added a reviewer: libc++.
aaron.ballman added a comment.
This revision now requires review to proceed.

LGTM but I'm adding libc++ as a blocking reviewer because there are questions about how well this interacts with their `stddef.h` (especially the `nullptr_t` bits): https://github.com/llvm/llvm-project/blob/main/libcxx/include/stddef.h



================
Comment at: clang/lib/Headers/stddef.h:16
+    defined(__need_wint_t) ||                                                  \
+    (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1)
 
----------------
iana wrote:
> aaron.ballman wrote:
> > C23 K.3.1.1p2: The functions, macros, and types declared or defined in K.3 and its subclauses are declared and defined by their respective headers if __STDC_WANT_LIB_EXT1__ is defined as a macro which expands to the integer constant 1 at the point in the source file where the appropriate header is first included.
> > 
> > So I don't think this should be `>= 1`. Same below. (Though I notice we seem to do this in other places, so perhaps that's more of a general cleanup we should make?)
> `>=1` is what stddef.h was already doing, so I'd vote do this later as general cleanup.
That sounds reasonable to me!


================
Comment at: clang/test/Headers/stddef.c:7
+
+ptrdiff_t p0; // c99-error{{unknown}} c11-error{{unknown}} c23-error{{unknown}}
+size_t s0; // c99-error{{unknown}} c11-error{{unknown}} c23-error{{unknown}}
----------------
iana wrote:
> aaron.ballman wrote:
> > At least one of these `unknown` errors should be fully spelled out (the rest can then be assumed to be the same wording as the long-form).
> Let me know how this looks, I can just fully expand all of them if you prefer. I was going by stddefneeds.cpp as an example.
This works fine -- I would have also been happy if only `ptrdiff_t` was fully spelled out and the rest used `unknown` (we can infer they're all the same diagnostic from that).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157757/new/

https://reviews.llvm.org/D157757



More information about the cfe-commits mailing list