Unicode identifier rules updated for C++29.
Implements C++29 P3658R1, adjusting Unicode identifier character rules and differentiating between C++ and C compatibility.
This commit updates libcpp to implement the C++29 standard’s changes to identifier rules based on new Unicode recommendations (P3658R1). It introduces a distinction between characters that are valid for C++ identifiers (XID_Start/XID_Continue) and those valid for C compatibility (ID_Compat_Math_Start/ID_Compat_Math_Continue). For C++98 through C++26, both sets are accepted. However, for C++23 and C++2Y, the compatibile characters are only accepted in non-pedantic modes, ensuring stricter adherence to evolving standards.
In Details
Implements C++29 P3658R1 by modifying makeucnid and related functions (read_proplist, write_table) in libcpp. It introduces a NONC enumerator to differentiate between standard XID characters and compatibility math characters. The cpp_check_xid_property function now returns 0 if the NONC bit is set, and ucn_valid_in_identifier differentiates behavior based on pedantic settings for C++23/C2Y. The __cpp_identifier_conformance macro is updated, and new test cases are added.
- Unicode recommendations
- Guidelines and specifications from the Unicode Consortium regarding character properties, normalization, and identification, which are often incorporated into programming language standards.
- identifier conformance
- The rules a programming language compiler follows to determine whether a sequence of characters is valid as an identifier (e.g., variable name).
- pedantic
- A compiler mode that enforces stricter adherence to the language standard, often rejecting constructs that are technically allowed but potentially problematic or non-portable.
- libcpp
- The C++ standard library implementation used by GCC, which includes the preprocessor (cpp).
- C++29
- The upcoming revision of the C++ programming language standard. Features designated for C++29 are often ratified through papers and then implemented in compilers.