Ada: Fix another fallout of recent changes to handling of static aggregates
Prevents incorrect static aggregate flag on Ada arrays with dynamic component subtypes.
This commit addresses an issue where the Compile_Time_Known_Aggregate flag was incorrectly set for Ada array aggregates. This occurred when all elements were static, but the array’s subtype was dynamic due to its component subtype being dynamic. The compiler now prevents setting this flag in such cases, ensuring these aggregates are handled correctly by the backend.
In Details
A recent change in aggregate handling in gcc/ada/exp_aggr.adb led to the Compile_Time_Known_Aggregate flag being incorrectly set for array aggregates whose component subtype is dynamic, even if the array's elements themselves are static. This commit modifies Convert_To_Positional and Expand_Record_Aggregate.Build_Back_End_Aggregate to not set this flag if the aggregate's type size is not known at compile time. Additionally, sem_aggr.adb ensures Size_Known_At_Compile_Time is set on the subtype.
- Static Aggregate
- In Ada, an aggregate whose value is known at compile time. This allows for certain optimizations and use in contexts requiring compile-time constants.
- 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.
- Dynamic Size
- In Ada, a type or subtype that can have a size determined at runtime, often dependent on discriminant values or data associated with an object.