[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
Mon Aug 14 08:31:59 PDT 2023


aaron.ballman added a subscriber: ldionne.
aaron.ballman added inline comments.


================
Comment at: clang/lib/Headers/stddef.h:16
+    defined(__need_wint_t) ||                                                  \
+    (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1)
 
----------------
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?)


================
Comment at: clang/lib/Headers/stddef.h:118-122
+#ifdef __cplusplus
+namespace std {
+typedef decltype(nullptr) nullptr_t;
+}
+using ::std::nullptr_t;
----------------
Related:

https://github.com/llvm/llvm-project/issues/37564
https://cplusplus.github.io/LWG/issue3484

CC @ldionne


================
Comment at: clang/test/Headers/stddef.c:1-3
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c99 -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c11 -std=c11 %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c23 -std=c23 %s
----------------
Are the triples necessary? Better if we can remove them.


================
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}}
----------------
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).


================
Comment at: clang/test/Headers/stddefneeds.c:1-2
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c99 -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9.0 -verify=c23 -std=c23 %s
+
----------------
Do we need the triples?


================
Comment at: clang/test/Headers/stddefneeds.c:8
+
+ptrdiff_t p0; // c99-error{{unknown}} c23-error{{unknown}}
+size_t s0; // c99-error{{unknown}} c23-error{{unknown}}
----------------
Should spell out one of these.


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