aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-08-09 15:30:09 +0200
committerMartin Liska <mliska@suse.cz>2022-08-09 15:30:09 +0200
commit9fce2fbb1dff9f090d98a056df1da459ba45f16f (patch)
tree097d3bc54e8fd0f304bb8c4d99667289e9f3fd25 /gcc/c-family
parentb3a187edd33b89acf19ba46f3b8070d7c977ac57 (diff)
parent04284176d549ff2565406406a6d53ab4ba8e507d (diff)
downloadgcc-9fce2fbb1dff9f090d98a056df1da459ba45f16f.zip
gcc-9fce2fbb1dff9f090d98a056df1da459ba45f16f.tar.gz
gcc-9fce2fbb1dff9f090d98a056df1da459ba45f16f.tar.bz2
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog14
-rw-r--r--gcc/c-family/c-lex.cc13
-rw-r--r--gcc/c-family/c-opts.cc5
3 files changed, 26 insertions, 6 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 68fc6e2..63277a5 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,17 @@
+2022-08-08 Tom Honermann <tom@honermann.net>
+
+ PR preprocessor/106426
+ * c-opts.cc (c_common_post_options): Assign cpp_opts->unsigned_utf8char
+ subject to -fchar8_t, -fsigned-char, and/or -funsigned-char.
+
+2022-08-08 Tom Honermann <tom@honermann.net>
+
+ * c-lex.cc (lex_string, lex_charconst): Use char8_t as the type
+ of CPP_UTF8CHAR and CPP_UTF8STRING when char8_t support is
+ enabled.
+ * c-opts.cc (c_common_post_options): Set flag_char8_t if
+ targeting C2x.
+
2022-07-31 Lewis Hyatt <lhyatt@gmail.com>
PR c++/66290
diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc
index 8bfa4f4..0b6f94e 100644
--- a/gcc/c-family/c-lex.cc
+++ b/gcc/c-family/c-lex.cc
@@ -1352,7 +1352,14 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string, bool translate)
default:
case CPP_STRING:
case CPP_UTF8STRING:
- value = build_string (1, "");
+ if (type == CPP_UTF8STRING && flag_char8_t)
+ {
+ value = build_string (TYPE_PRECISION (char8_type_node)
+ / TYPE_PRECISION (char_type_node),
+ ""); /* char8_t is 8 bits */
+ }
+ else
+ value = build_string (1, "");
break;
case CPP_STRING16:
value = build_string (TYPE_PRECISION (char16_type_node)
@@ -1425,9 +1432,7 @@ lex_charconst (const cpp_token *token)
type = char16_type_node;
else if (token->type == CPP_UTF8CHAR)
{
- if (!c_dialect_cxx ())
- type = unsigned_char_type_node;
- else if (flag_char8_t)
+ if (flag_char8_t)
type = char8_type_node;
else
type = char_type_node;
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index 4e14636..9833e50 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1059,9 +1059,10 @@ c_common_post_options (const char **pfilename)
if (flag_sized_deallocation == -1)
flag_sized_deallocation = (cxx_dialect >= cxx14);
- /* char8_t support is new in C++20. */
+ /* char8_t support is implicitly enabled in C++20 and C2X. */
if (flag_char8_t == -1)
- flag_char8_t = (cxx_dialect >= cxx20);
+ flag_char8_t = (cxx_dialect >= cxx20) || flag_isoc2x;
+ cpp_opts->unsigned_utf8char = flag_char8_t ? 1 : cpp_opts->unsigned_char;
if (flag_extern_tls_init)
{