[PATCH] D120244: [clang][sema] Enable first-class bool support for C2x

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 8 05:10:47 PST 2022


aaron.ballman added a comment.

In D120244#3362215 <https://reviews.llvm.org/D120244#3362215>, @tbaeder wrote:

> Thanks for the links to the papers. What's the best way of updating https://clang.llvm.org/c_status.html#c2x with the new papers?

I update that page from the WG14 editor's report (or the latest working draft) so that I can be sure we're tracking what actually made it into the standard. I'll try to get it right when I add these papers to the list, but you may want to keep your eyes peeled when I update the page to double-check just in case.

> I added the changes to `stdbool.h`, but I haven't been able to come up with a good way of testing them...

I think stdbool.h should get a deprecation warning, and that will make it testable. e.g., https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdnoreturn.h#L16



================
Comment at: clang/lib/Headers/stdbool.h:13-14
 
+/* true, false and bool are first-class keywords in C2x */
+#if __STDC_VERSION__ < 202000L
 /* Don't define bool, true, and false in C++, except as a GNU extension. */
----------------
FWIW, I've been using `__STDC_VERSION__ > 201710L` for my C2x predicates. My plan was to switch them to use the C2x `__STDC_VERSION__` value once that's been finalized. Either approach works though.


================
Comment at: clang/lib/Headers/stdbool.h:16
 /* Don't define bool, true, and false in C++, except as a GNU extension. */
 #ifndef __cplusplus
 #define bool _Bool
----------------
We're inside an `#if __STDC_VERSION__` check here, so I think this will now always evaluate to true.


================
Comment at: clang/lib/Headers/stdbool.h:23-28
 #if __cplusplus < 201103L
 /* For C++98, define bool, false, true as a GNU extension. */
-#define bool  bool
+#define bool bool
 #define false false
-#define true  true
+#define true true
+#endif
----------------
This seems wrong now too.


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

https://reviews.llvm.org/D120244



More information about the cfe-commits mailing list