c++/reflection: reject bare [: bases_of(...)[0] :]
Correctly rejects ill-formed reflection expressions involving base class relationships without an object.
This change rejects C++ reflection expressions that attempt to splice a base class relationship without specifying an object. The standard implies such expressions, which reference a direct base class relationship, require an object context, and this commit enforces that rule to prevent crashes in the compiler’s gimplify phase.
In Details
The C++ reflection implementation rejects attempts to use [: bases_of(T, ctx)[0] :] in splice expressions when no object is specified. This adheres to the interpretation of C++ standards like [expr.prim.splice]/2.4 and P3293, which imply that designating a direct base class relationship via splice requires an explicit object, preventing ill-formed expressions from causing gimplification failures.
- C++ reflection
- A feature in C++ that allows code to inspect and manipulate its own structure at compile time or runtime, often used for metaprogramming and introspection.
- splice
- A C++ expression construct used in reflection to designate a relationship or entity within the reflected code.
- bases_of
- A C++ reflection utility likely used to query the base classes of a given type.
- gimplify
- The process in GCC where C++ abstract syntax tree (AST) is converted into GIMPLE, GCC's intermediate representation, before further optimizations.