aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include/cpplib.h
diff options
context:
space:
mode:
authorJoseph Myers <josmyers@redhat.com>2024-12-03 13:01:58 +0000
committerJoseph Myers <josmyers@redhat.com>2024-12-03 13:01:58 +0000
commitf3b5de944ad6d1f6a10f819b816c2ba234ecd8c0 (patch)
tree45c15b02d46a42f4ffc5167fff2fae29ebc36b0e /libcpp/include/cpplib.h
parentaf9a3fe6a52974252516b3eea4c5ab5caae47b4b (diff)
downloadgcc-f3b5de944ad6d1f6a10f819b816c2ba234ecd8c0.zip
gcc-f3b5de944ad6d1f6a10f819b816c2ba234ecd8c0.tar.gz
gcc-f3b5de944ad6d1f6a10f819b816c2ba234ecd8c0.tar.bz2
preprocessor: Adjust C rules on UCNs for C23 [PR117162]
As noted in bug 117162, C23 changed some rules on UCNs to match C++ (this was a late change agreed in the resolution to CD2 comment US-032, implementing changes from N3124), which we need to implement. Allow UCNs below 0xa0 outside identifiers for C, with a pedwarn-if-pedantic before C23 (and a warning with -Wc11-c23-compat) except for the always-allowed cases of UCNs for $ @ `. Also as part of that change, do not allow \u0024 in identifiers as equivalent to $ for C23. Bootstrapped with no regressions for x86_64-pc-linux-gnu. PR c/117162 libcpp/ * include/cpplib.h (struct cpp_options): Add low_ucns. * init.cc (struct lang_flags, lang_defaults): Add low_ucns. (cpp_set_lang): Set low_ucns * charset.cc (_cpp_valid_ucn): For C, allow UCNs below 0xa0 outside identifiers, with a pedwarn if pedantic before C23 or a warning with -Wc11-c23-compat. Do not allow \u0024 in identifiers for C23. gcc/testsuite/ * gcc.dg/cpp/c17-ucn-1.c, gcc.dg/cpp/c17-ucn-2.c, gcc.dg/cpp/c17-ucn-3.c, gcc.dg/cpp/c17-ucn-4.c, gcc.dg/cpp/c23-ucn-2.c, gcc.dg/cpp/c23-ucnid-2.c: New tests. * c-c++-common/cpp/delimited-escape-seq-3.c, c-c++-common/cpp/named-universal-char-escape-3.c, gcc.dg/cpp/c23-ucn-1.c, gcc.dg/cpp/c2y-delimited-escape-seq-3.c: Update expected messages * gcc.dg/cpp/ucs.c: Use -pedantic-errors. Update expected messages.
Diffstat (limited to 'libcpp/include/cpplib.h')
-rw-r--r--libcpp/include/cpplib.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index e73f77e..298b434 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -557,6 +557,9 @@ struct cpp_options
/* Nonzero for C++23 named universal character escape sequences. */
unsigned char named_uc_escape_seqs;
+ /* Nonzero for C++ and C23 UCNs for characters below 0xa0. */
+ unsigned char low_ucns;
+
/* Nonzero for C2Y 0o prefixed octal integer constants. */
unsigned char octal_constants;