gnu/gcc/c68beaef7a1760bfebf43d358f2315cccd99faae Ada: Fix too large secondary stack allocation for aggregate return
This is a regression present on the mainline and 15 branch. The problematic
allocation may occur when the result type of the function is a discriminated
record type with defaulted discriminants. Although it had been present for
a long time when the type is limited, the problem was recently propagated
to nonlimited types because of an optimization.
While the fix is a one-liner, the change also makes it so that SS_Allocate
raises a Storage_Error when the size overflows, like the other allocators.
gcc/ada/
* exp_ch6.adb (Expand_Simple_Function_Return): Use a constant return
object when the simple return is rewritten as an extended one.
* libgnat/s-secsta.adb (SS_Allocate): Raise Storage_Error if the
requested size is negative.
* libgnat/s-secsta__cheri.adb (SS_Allocate): Likewise.
gcc/testsuite/
* gnat.dg/aggr35.adb: New test.
* gnat.dg/aggr35_pkg.ads, gnat.dg/aggr35_pkg.adb: New helper.
6 files changed