Ada: Add support for static comparison of aggregates of discrete array types
Enables compile-time comparison for Ada discrete array aggregates.
This change extends Ada’s compile-time evaluation capabilities to support static comparisons of aggregates for all discrete array types, not just strings. It introduces new functions and modifies existing ones in sem_eval.adb to handle these comparisons, enabling optimizations and checks for constant array expressions.
In Details
The Ada front-end lacked support for compile-time comparison of aggregates beyond string types. This commit introduces Expr_Value_A and modifies Compile_Time_Compare in sem_eval.adb to handle discrete array types. Compile_Time_Known_Value is updated to return true for aggregates with the Compile_Time_Known_Aggregate flag set (excluding strings). Additionally, logic in exp_pakd.adb and sem_res.adb is adjusted for consistency.
- Static Comparison
- In the context of a compiler, evaluating a comparison operation at compile time rather than at runtime. This is possible when all operands are known constants.
- Discrete Array Type
- In Ada, an array whose component type is a discrete type (enumerations or integers). Examples include arrays of booleans, characters, or integers.
- Aggregate
- In Ada, an aggregate is an expression that denotes a value of a composite type (like records or arrays) by specifying the values of its components.
- Compile-time Known Aggregate
- An internal flag used by the GCC Ada front-end to mark aggregates whose values and structure are fully determined during compilation.