]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Elide temporary for aliased array with unconstrained nominal subtype
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 16 Oct 2023 19:16:38 +0000 (21:16 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 7 Nov 2023 09:15:04 +0000 (10:15 +0100)
commita2e4afc6f6bd0fd3c3894a2192fcc09e0b60f0be
treee392f4cfef910e72c0edcbbc6ff6734c4cd4edb5
parentde4f7051af5a00c3127cfd5c77f1a5b6d4000e42
ada: Elide temporary for aliased array with unconstrained nominal subtype

When the array is initialized with the result of a call to a function whose
result type is unconstrained, then the result is allocated with its bounds,
so the array can be rewritten as a renaming of the result in this case too.

gcc/ada/

* exp_ch3.adb (Expand_N_Object_Declaration): Fold initialization
expression of Nominal_Subtype_Is_Constrained_Array constant into
the computation of Rewrite_As_Renaming and remove the constant.
Set it to True for an aliased array with unconstrained nominal
subtype if the subtype of the expression is also unconstrained.
gcc/ada/exp_ch3.adb