aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2022-09-23 18:06:34 -0400
committerMarek Polacek <polacek@redhat.com>2022-09-26 13:34:04 -0400
commit567329fdd9d65a1e6254206fefff89fa151ba7f3 (patch)
tree781fe7411780693ba3b1c35ff80fd51f756e8d40 /gcc/c-family
parent5e77d4082fa845f1182641a93cfbae71984244d2 (diff)
downloadgcc-567329fdd9d65a1e6254206fefff89fa151ba7f3.zip
gcc-567329fdd9d65a1e6254206fefff89fa151ba7f3.tar.gz
gcc-567329fdd9d65a1e6254206fefff89fa151ba7f3.tar.bz2
c++: P2513R4, char8_t Compatibility and Portability Fix [PR106656]
P0482R6, which added char8_t, didn't allow const char arr[] = u8"howdy"; because it said "Declarations of arrays of char may currently be initialized with UTF-8 string literals. Under this proposal, such initializations would become ill-formed." This caused too many issues, so P2513R4 alleviates some of those compatibility problems. In particular, "Arrays of char or unsigned char may now be initialized with a UTF-8 string literal." This restriction has been lifted for initialization only, not implicit conversions. Also, my reading is that 'signed char' was excluded from the allowable conversions. This is supposed to be treated as a DR in C++20. PR c++/106656 gcc/c-family/ChangeLog: * c-cppbuiltin.cc (c_cpp_builtins): Update value of __cpp_char8_t for C++20. gcc/cp/ChangeLog: * typeck2.cc (array_string_literal_compatible_p): Allow initializing arrays of char or unsigned char by a UTF-8 string literal. gcc/testsuite/ChangeLog: * g++.dg/cpp23/feat-cxx2b.C: Adjust. * g++.dg/cpp2a/feat-cxx2a.C: Likewise. * g++.dg/ext/char8_t-feature-test-macro-2.C: Likewise. * g++.dg/ext/char8_t-init-2.C: Likewise. * g++.dg/cpp2a/char8_t3.C: New test. * g++.dg/cpp2a/char8_t4.C: New test.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-cppbuiltin.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index a1557eb..b709f84 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -1112,7 +1112,7 @@ c_cpp_builtins (cpp_reader *pfile)
if (flag_threadsafe_statics)
cpp_define (pfile, "__cpp_threadsafe_static_init=200806L");
if (flag_char8_t)
- cpp_define (pfile, "__cpp_char8_t=201811L");
+ cpp_define (pfile, "__cpp_char8_t=202207L");
#ifndef THREAD_MODEL_SPEC
/* Targets that define THREAD_MODEL_SPEC need to define
__STDCPP_THREADS__ in their config/XXX/XXX-c.c themselves. */