aboutsummaryrefslogtreecommitdiff
path: root/gcc/ginclude
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2020-10-29 15:05:33 +0000
committerJoseph Myers <joseph@codesourcery.com>2020-10-29 15:06:26 +0000
commit40749db75caff2fed7b7053e0d1868feaa21bcb4 (patch)
treed52db1f98393d6f74dc2edf5198e2f8a5e0b02f8 /gcc/ginclude
parent8c84486bba104399b7e544cb1ba343646d39ea0a (diff)
downloadgcc-40749db75caff2fed7b7053e0d1868feaa21bcb4.zip
gcc-40749db75caff2fed7b7053e0d1868feaa21bcb4.tar.gz
gcc-40749db75caff2fed7b7053e0d1868feaa21bcb4.tar.bz2
stdbool.h: Update true and false expansions for C2x
C2x has changed the expansions of the true and false macros in <stdbool.h> so that they have type _Bool (including in #if conditions, i.e. an unsigned type in that context). Use the new expansions in GCC's <stdbool.h> for C2x. See bug 82272 for related discussion (but this patch does *not* implement the warning discussed there). Note that it's possible there may be a further change to make bool, true and false keywords (there was support in principle for that at the April WG14 meeting). But currently these expansions of type _Bool are what C2x requires and there isn't actually a paper before WG14 at present that would introduce the new keywords. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/ 2020-10-29 Joseph Myers <joseph@codesourcery.com> * ginclude/stdbool.h [__STDC_VERSION__ > 201710L] (true, false): Define with type _Bool. gcc/testsuite/ 2020-10-29 Joseph Myers <joseph@codesourcery.com> * gcc.dg/c11-bool-1.c, gcc.dg/c2x-bool-1.c, gcc.dg/c99-bool-4.c: New tests.
Diffstat (limited to 'gcc/ginclude')
-rw-r--r--gcc/ginclude/stdbool.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/ginclude/stdbool.h b/gcc/ginclude/stdbool.h
index 1b56498..2355422 100644
--- a/gcc/ginclude/stdbool.h
+++ b/gcc/ginclude/stdbool.h
@@ -31,8 +31,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#ifndef __cplusplus
#define bool _Bool
+#if defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L
+#define true ((_Bool)+1u)
+#define false ((_Bool)+0u)
+#else
#define true 1
#define false 0
+#endif
#else /* __cplusplus */