diff options
author | Martin Liska <mliska@suse.cz> | 2022-08-09 15:30:09 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-08-09 15:30:09 +0200 |
commit | 9fce2fbb1dff9f090d98a056df1da459ba45f16f (patch) | |
tree | 097d3bc54e8fd0f304bb8c4d99667289e9f3fd25 /gcc/c | |
parent | b3a187edd33b89acf19ba46f3b8070d7c977ac57 (diff) | |
parent | 04284176d549ff2565406406a6d53ab4ba8e507d (diff) | |
download | gcc-9fce2fbb1dff9f090d98a056df1da459ba45f16f.zip gcc-9fce2fbb1dff9f090d98a056df1da459ba45f16f.tar.gz gcc-9fce2fbb1dff9f090d98a056df1da459ba45f16f.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c/c-parser.cc | 16 | ||||
-rw-r--r-- | gcc/c/c-typeck.cc | 2 |
3 files changed, 23 insertions, 3 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index cffb462..b5ecf92 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,11 @@ +2022-08-08 Tom Honermann <tom@honermann.net> + + * c-parser.cc (c_parser_string_literal): Use char8_t as the type + of CPP_UTF8STRING when char8_t support is enabled. + * c-typeck.cc (digest_init): Allow initialization of an array + of character type by a string literal with type array of + char8_t. + 2022-08-01 David Malcolm <dmalcolm@redhat.com> * c-typeck.cc (build_c_cast): Quote names of address spaces in diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 92049d1..fa93959 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -7447,7 +7447,14 @@ c_parser_string_literal (c_parser *parser, bool translate, bool wide_ok) 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) @@ -7472,9 +7479,14 @@ c_parser_string_literal (c_parser *parser, bool translate, bool wide_ok) { default: case CPP_STRING: - case CPP_UTF8STRING: TREE_TYPE (value) = char_array_type_node; break; + case CPP_UTF8STRING: + if (flag_char8_t) + TREE_TYPE (value) = char8_array_type_node; + else + TREE_TYPE (value) = char_array_type_node; + break; case CPP_STRING16: TREE_TYPE (value) = char16_array_type_node; break; diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 8514488..d37de2a 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -8056,7 +8056,7 @@ digest_init (location_t init_loc, tree type, tree init, tree origtype, if (char_array) { - if (typ2 != char_type_node) + if (typ2 != char_type_node && typ2 != char8_type_node) incompat_string_cst = true; } else if (!comptypes (typ1, typ2)) |