Ada: Fix too small dynamic allocation for mutably tagged type
Corrects dynamic allocation size for Ada mutably tagged types.
This commit corrects an issue in GCC’s Ada front-end where dynamic allocations for mutably tagged types were using the size of the root type instead of the maximum size specified by the Size'Class aspect. The Expand_Allocator_Expression and Expand_N_Allocator routines have been updated to allocate the correct, larger size when the designated type is mutably tagged, ensuring proper memory management for these types.
In Details
In the GCC Ada front-end, the Expand_Allocator_Expression and Expand_N_Allocator procedures were incorrectly calculating the allocation size for new expressions whose designated type was a mutably tagged type. Instead of using the size defined by the Size'Class aspect of the specific subtype, they were defaulting to the size of the root type. This commit ensures that the allocated memory is sufficient for the actual mutably tagged type, preventing potential buffer overflows or memory corruption when instances of such types are dynamically allocated.
- mutably tagged type
- In Ada, a tagged type that can be modified after its creation. It allows for dynamic dispatching and subtype extension.
- Size'Class aspect
- An Ada aspect that specifies the size of a type. For tagged types, it can be used to define a specific storage size for subtypes.
- Root type
- The base type in a type hierarchy from which other types are derived.