Corrected identifier character property checks for Rust frontend.
Fixes `cpp_check_xid_property` to accurately distinguish between Unicode XID_Start and XID_Continue properties for identifier validation.
This commit corrects the cpp_check_xid_property function, which is used by the Rust frontend for identifier validation. The function previously misapplied Unicode character properties, incorrectly classifying characters with only the XID_Continue property as valid starting characters for identifiers. The fix ensures that only characters with the XID_Start property are accepted as initial identifier characters, aligning with Unicode standards and preventing potential issues in languages like Rust that rely on these precise checks.
In Details
The cpp_check_xid_property function in charset.cc, intended for Rust FE identifier validation, incorrectly mapped Unicode XID properties. Characters with only XID_Continue (NXX23 bit set) were incorrectly classified as CPP_XID_START | CPP_XID_CONTINUE. The patch corrects this logic: CXX23 implies XID_Start, NXX23 implies XID_Continue. Only when CXX23 is set and NXX23 is not, both bits are returned. If both CXX23 and NXX23 are set, only CPP_XID_CONTINUE is returned.
- XID_Start
- A Unicode general category property indicating characters that can be the first character of an identifier.
- XID_Continue
- A Unicode general category property indicating characters that can be subsequent characters within an identifier.
- identifier
- A name used to identify variables, functions, types, or other entities in a programming language.
- Rust frontend
- The part of the GCC compiler specifically designed to parse and process Rust source code.
- Unicode properties
- Metadata associated with Unicode characters, such as their general category (e.g., letter, number), script, or specific properties like XID_Start and XID_Continue, used for character classification and validation.