diff options
author | Joseph Myers <joseph@codesourcery.com> | 2022-09-07 13:56:25 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2022-09-07 13:56:46 +0000 |
commit | 0a91bdaf177409a2a5e7895bce4f0e7091b4b3ca (patch) | |
tree | 403ae03d079179e0a3cf9fc3096c4c3b8e763e44 /libcpp/include/cpplib.h | |
parent | 7abcdb06e31d82d4933cb6e0a626c3ccb28fa0c3 (diff) | |
download | gcc-0a91bdaf177409a2a5e7895bce4f0e7091b4b3ca.zip gcc-0a91bdaf177409a2a5e7895bce4f0e7091b4b3ca.tar.gz gcc-0a91bdaf177409a2a5e7895bce4f0e7091b4b3ca.tar.bz2 |
c: New C2x keywords
C2x follows C++ in making alignas, alignof, bool, false,
static_assert, thread_local and true keywords; implement this
accordingly. This implementation makes them normal keywords in C2x
mode just like any other keyword (C2x leaves open the possibility of
implementation using predefined macros instead - thus, there aren't
any testcases asserting that they aren't macros). As in C++ and
previous versions of C, true and false are handled like signed 1 and 0
in #if (there was an intermediate state in some C2x drafts where they
had different macro expansions that were unsigned in #if).
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
As with the removal of unprototyped functions, this change has a high
risk of breaking some old code and people doing GNU/Linux distribution
builds may wish to see how much is broken in a build with a -std=gnu2x
default.
gcc/
* ginclude/stdalign.h [defined __STDC_VERSION__ &&
__STDC_VERSION__ > 201710L]: Disable all content.
* ginclude/stdbool.h [defined __STDC_VERSION__ && __STDC_VERSION__
> 201710L] (bool, true, false): Do not define.
gcc/c-family/
* c-common.cc (c_common_reswords): Use D_C2X instead of D_CXXONLY
for alignas, alignof, bool, false, static_assert, thread_local and
true.
gcc/c/
* c-parser.cc (c_parser_static_assert_declaration_no_semi)
(c_parser_alignas_specifier, c_parser_alignof_expression): Allow
for C2x spellings of keywords.
(c_parser_postfix_expression): Handle RID_TRUE and RID_FALSE.
gcc/testsuite/
* gcc.dg/c11-keywords-1.c, gcc.dg/c2x-align-1.c,
gcc.dg/c2x-align-6.c, gcc.dg/c2x-bool-2.c,
gcc.dg/c2x-static-assert-3.c, gcc.dg/c2x-static-assert-4.c,
gcc.dg/c2x-thread-local-1.c: New tests.
* gcc.dg/c2x-bool-1.c: Update expectations.
libcpp/
* include/cpplib.h (struct cpp_options): Add true_false.
* expr.cc (eval_token): Check true_false not cplusplus to
determine whether to handle true and false keywords.
* init.cc (struct lang_flags): Add true_false.
(lang_defaults): Update.
(cpp_set_lang): Set true_false.
Diffstat (limited to 'libcpp/include/cpplib.h')
-rw-r--r-- | libcpp/include/cpplib.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index c25bcf2..2db1e9c 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -526,6 +526,9 @@ struct cpp_options /* Nonzero for C++23 delimited escape sequences. */ unsigned char delimited_escape_seqs; + /* Nonzero for 'true' and 'false' in #if expressions. */ + unsigned char true_false; + /* Holds the name of the target (execution) character set. */ const char *narrow_charset; |