Implement P0482R5, char8_t: A type for UTF-8 characters and strings
authorTom Honermann <tom@honermann.net>
Mon, 14 Jan 2019 19:55:51 +0000 (19:55 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 14 Jan 2019 19:55:51 +0000 (14:55 -0500)
commit2d91f79dc990f81dcea89a5087cad566238b2456
treeae9137b811a3a0bdada65dbb8a6ed5dba9d24b0e
parent23db6ced33c245c38c147c31011bbafa392e4328
Implement P0482R5, char8_t: A type for UTF-8 characters and strings

gcc/cp/
* cvt.c (type_promotes_to): Handle char8_t promotion.
* decl.c (grokdeclarator): Handle invalid type specifier
combinations involving char8_t.
* lex.c (init_reswords): Add char8_t as a reserved word.
* mangle.c (write_builtin_type): Add name mangling for char8_t (Du).
* parser.c (cp_keyword_starts_decl_specifier_p)
(cp_parser_simple_type_specifier): Recognize char8_t as a simple
type specifier.
(cp_parser_string_literal): Use char8_array_type_node for the type
of CPP_UTF8STRING.
(cp_parser_set_decl_spec_type): Tolerate char8_t typedefs in system
headers.
* rtti.c (emit_support_tinfos): type_info support for char8_t.
* tree.c (char_type_p): Recognize char8_t as a character type.
* typeck.c (string_conv_p): Handle conversions of u8 string
literals of char8_t type.
(check_literal_operator_args): Handle UDLs with u8 string literals
of char8_t type.
* typeck2.c (ordinary_char_type_p): New.
(digest_init_r): Disallow initializing a char array with a u8 string
literal.
gcc/c-family/
* c-common.c (c_common_reswords): Add char8_t.
(fix_string_type): Use char8_t for the type of u8 string literals.
(c_common_get_alias_set): char8_t doesn't alias.
(c_common_nodes_and_builtins): Define char8_t as a builtin type in
C++.
(c_stddef_cpp_builtins): Add __CHAR8_TYPE__.
(keyword_begins_type_specifier): Add RID_CHAR8.
* c-common.h (rid): Add RID_CHAR8.
(c_tree_index): Add CTI_CHAR8_TYPE and CTI_CHAR8_ARRAY_TYPE.
Define D_CXX_CHAR8_T and D_CXX_CHAR8_T_FLAGS.
Define char8_type_node and char8_array_type_node.
* c-cppbuiltin.c (cpp_atomic_builtins): Predefine
__GCC_ATOMIC_CHAR8_T_LOCK_FREE.
(c_cpp_builtins): Predefine __cpp_char8_t.
* c-lex.c (lex_string): Use char8_array_type_node as the type of
CPP_UTF8STRING.
(lex_charconst): Use char8_type_node as the type of CPP_UTF8CHAR.
* c-opts.c: If not otherwise specified, enable -fchar8_t when
targeting C++2a.
* c.opt: Add the -fchar8_t command line option.
libiberty/
* cp-demangle.c (cplus_demangle_builtin_types)
(cplus_demangle_type): Add name demangling for char8_t (Du).
* cp-demangle.h: Increase D_BUILTIN_TYPE_COUNT to accommodate the
new char8_t type.

From-SVN: r267923
74 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-family/c-cppbuiltin.c
gcc/c-family/c-lex.c
gcc/c-family/c-opts.c
gcc/c-family/c.opt
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/cvt.c
gcc/cp/decl.c
gcc/cp/lex.c
gcc/cp/mangle.c
gcc/cp/parser.c
gcc/cp/rtti.c
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/cp/typeck2.c
gcc/defaults.h
gcc/doc/invoke.texi
gcc/testsuite/c-c++-common/raw-string-13.c
gcc/testsuite/c-c++-common/raw-string-15.c
gcc/testsuite/g++.dg/cpp0x/constexpr-wstring2.C
gcc/testsuite/g++.dg/cpp0x/udlit-implicit-conv-neg-char8_t.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/udlit-resolve-char8_t.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/udlit-string-length.C
gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.C
gcc/testsuite/g++.dg/cpp0x/udlit-string-literal.h
gcc/testsuite/g++.dg/cpp1z/udlit-utf8char.C
gcc/testsuite/g++.dg/cpp1z/utf8.C
gcc/testsuite/g++.dg/cpp2a/char8_t1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/char8_t2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/feat-cxx2a.C
gcc/testsuite/g++.dg/ext/char8_t-aliasing-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-char-literal-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-char-literal-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-deduction-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-deduction-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-feature-test-macro-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-feature-test-macro-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-init-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-init-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-keyword-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-keyword-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-limits-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-overload-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-overload-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-predefined-macros-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-predefined-macros-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-sizeof-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-specialization-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-specialization-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-string-literal-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-string-literal-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-type-specifier-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-type-specifier-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-typedef-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-typedef-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-udl-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/char8_t-udl-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/utf-array-short-wchar.C
gcc/testsuite/g++.dg/ext/utf-array.C
gcc/testsuite/g++.dg/ext/utf-cvt-char8_t.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/utf-cxx98.C
gcc/testsuite/g++.dg/ext/utf-dflt.C
gcc/testsuite/g++.dg/ext/utf-gnuxx98.C
gcc/testsuite/g++.dg/ext/utf-type-char8_t.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/utf8-1.C
gcc/testsuite/g++.dg/ext/utf8-2.C
gcc/testsuite/g++.dg/warn/Wformat-ranges-c++11.C
libiberty/ChangeLog
libiberty/cp-demangle.c
libiberty/cp-demangle.h