C++: Implement C++29 designated initializers for base classes.
Adds support for C++29's designated initializers for base class members.
This commit implements the C++29 feature for designated initializers applied to base classes, based on the P2287R6 proposal. It modifies parsing to correctly handle sequences of non-designated and designated initializers, particularly for base class members. The implementation also refines lookup rules and ensures correct initialization when designators refer to members of base classes.
In Details
The C++ frontend now supports P2287R6, which extends designated initializers to base class subobjects. The cp_parser_initializer_list has been updated to allow non-designated clauses followed by designated clauses (for C++29, and as a pedwarned extension for C++20-C++26). Lookup logic has been adjusted: lookup_member serves as a fallback for get_class_binding, prioritizing NSDMs of the current class over base class ambiguities. The initialization process now correctly identifies base class fields and handles consecutive designators belonging to the same base class field via ``resh…
- designated initializer
- A C++ feature (C++20 and later) that allows specifying which member of a struct, class, or array is being initialized, using syntax like
.member = valueor[index] = value. - base class
- In C++ inheritance, a class from which another class derives.
- C++29
- The upcoming standard for the C++ programming language, including features like P2287R6.
- P2287R6
- A C++ standard proposal document related to designated initializers for base classes.
- NSDM
- Non-Static Data Member. A data member of a class that is not declared static.