From 36d20fa4a83d1a294462c2622ca76eac93465c2c Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 14 Oct 2022 23:07:50 +0000 Subject: preprocessor: C2x identifier rules C2x has, like C++, adopted rules for identifiers based directly on an unversioned normative reference to Unicode. Make libcpp follow those rules for c2x / gnu2x standards (this involves bringing back a flag separate from the C++ one for whether to use these identifier rules, but this time enabled for all C++ language versions since that was the conclusion adopted for C++ identifier handling). There is one change here that affects C++. I believe the new normative requirement for NFC only applies to identifiers, not to the use of identifier-continue characters in pp-numbers, where there is no such requirement and so the diagnostic ought to be a warning not a pedwarn in pp-numbers, and that this is the case for both C and C++. Bootstrapped with no regressions for x86_64-pc-linux-gnu. libcpp/ * charset.cc (ucn_valid_in_identifier): Check xid_identifiers not cplusplus to determine whether to use CXX23 and NXX23 flags. * include/cpplib.h (struct cpp_options): Add xid_identifiers. * init.cc (struct lang_flags, lang_defaults): Add xid_identifiers. (cpp_set_lang): Set xid_identifiers. * lex.cc (warn_about_normalization): Add parameter identifier. Only pedwarn about non-NFC for identifiers, not pp-numbers. (_cpp_lex_direct): Update calls to warn_about_normalization. gcc/testsuite/ * gcc.dg/cpp/c2x-ucnid-1-utf8.c, gcc.dg/cpp/c2x-ucnid-1.c: New tests. --- libcpp/include/cpplib.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libcpp/include/cpplib.h') diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index e97993e..d5ef12a 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -496,6 +496,10 @@ struct cpp_options in C11. */ unsigned char c11_identifiers; + /* Nonzero means extended identifiers allow the characters specified + by Unicode XID_Start and XID_Continue properties. */ + unsigned char xid_identifiers; + /* Nonzero for C++ 2014 Standard binary constants. */ unsigned char binary_constants; -- cgit v1.1