gcc/libcpp
Joseph Myers 7c5890cc0a Support UTF-8 character constants for C2x.
C2x adds u8'' character constants to C.  This patch adds the
corresponding GCC support.

Most of the support was already present for C++ and just needed
enabling for C2x.  However, in C2x these constants have type unsigned
char, which required corresponding adjustments in the compiler and the
preprocessor to give them that type for C.

For C, it seems clear to me that having type unsigned char means the
constants are unsigned in the preprocessor (and thus treated as having
type uintmax_t in #if conditionals), so this patch implements that.  I
included a conditional in the libcpp change to avoid affecting
signedness for C++, but I'm not sure if in fact these constants should
also be unsigned in the preprocessor for C++ in which case that
!CPP_OPTION (pfile, cplusplus) conditional would not be needed.

Bootstrapped with no regressions on x86_64-pc-linux-gnu.

gcc/c:
	* c-parser.c (c_parser_postfix_expression)
	(c_parser_check_literal_zero): Handle CPP_UTF8CHAR.
	* gimple-parser.c (c_parser_gimple_postfix_expression): Likewise.

gcc/c-family:
	* c-lex.c (lex_charconst): Make CPP_UTF8CHAR constants unsigned
	char for C.

gcc/testsuite:
	* gcc.dg/c11-utf8char-1.c, gcc.dg/c2x-utf8char-1.c,
	gcc.dg/c2x-utf8char-2.c, gcc.dg/c2x-utf8char-3.c,
	gcc.dg/gnu2x-utf8char-1.c: New tests.

libcpp:
	* charset.c (narrow_str_to_charconst): Make CPP_UTF8CHAR constants
	unsigned for C.
	* init.c (lang_defaults): Set utf8_char_literals for GNUC2X and
	STDC2X.

From-SVN: r278265
2019-11-14 20:18:33 +00:00
..
include Implement C++20 operator<=>. 2019-11-05 18:56:18 -05:00
po * zh_TW.po: Update. 2019-08-09 23:02:08 +01:00
ChangeLog Support UTF-8 character constants for C2x. 2019-11-14 20:18:33 +00:00
ChangeLog.jit
Makefile.in Update copyright years. 2019-01-01 13:31:55 +01:00
aclocal.m4 Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
charset.c Support UTF-8 character constants for C2x. 2019-11-14 20:18:33 +00:00
config.in Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
configure iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS. 2018-11-07 15:41:21 -07:00
configure.ac Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
directives-only.c [Preprocessor] small cleanups 2019-08-28 18:43:37 +00:00
directives.c re PR preprocessor/92296 (internal compiler error: Segmentation fault #pragma push_macro("__LINE__")) 2019-10-31 18:38:44 +01:00
errors.c Update copyright years. 2019-01-01 13:31:55 +01:00
expr.c Support decimal floating-point constants in C2x. 2019-10-11 23:22:52 +01:00
files.c [preprocessor/91639] #includes at EOF 2019-09-05 11:23:48 +00:00
identifiers.c Update copyright years. 2019-01-01 13:31:55 +01:00
init.c Support UTF-8 character constants for C2x. 2019-11-14 20:18:33 +00:00
internal.h re PR preprocessor/92296 (internal compiler error: Segmentation fault #pragma push_macro("__LINE__")) 2019-10-31 18:38:44 +01:00
lex.c Implement C++20 operator<=>. 2019-11-05 18:56:18 -05:00
line-map.c [linemap PATCH] Constify lookup 2019-10-15 12:03:04 +00:00
location-example.txt PR preprocessor/83173: Enhance -fdump-internal-locations output 2018-11-27 16:04:31 +00:00
macro.c PR c/66970 - Add __has_builtin() macro 2019-10-28 16:46:28 -06:00
makeucnid.c Update copyright years. 2019-01-01 13:31:55 +01:00
mkdeps.c PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs 2019-07-09 12:32:49 -06:00
pch.c Update copyright years. 2019-01-01 13:31:55 +01:00
symtab.c Improve memory statistics report readability. 2019-02-26 17:27:52 +00:00
system.h Update copyright years. 2019-01-01 13:31:55 +01:00
traditional.c PR c/66970 - Add __has_builtin() macro 2019-10-28 16:46:28 -06:00
ucnid.h Update copyright years. 2019-01-01 13:31:55 +01:00
ucnid.tab Update copyright years. 2019-01-01 13:31:55 +01:00