]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix crash on vector initialization
authorMarc Poulhiès <poulhies@adacore.com>
Mon, 27 Mar 2023 14:47:04 +0000 (16:47 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Sun, 5 Jan 2025 11:17:44 +0000 (12:17 +0100)
commite8b53a5263946be717169e2549eabf67e6a227ad
treeb3e3d4837fcf639de745ba3c859e9402a349296c
parent91e5cb07f92915315bb3f5b74a46cec4afabba07
ada: Fix crash on vector initialization

Initializing a vector using

 Vec : V.Vector := [Some_Type'(Some_Abstract_Type with F => 0)];

may crash the compiler. The expander marks the N_Extension_Aggregate for
delayed expansion which never happens and incorrectly ends up in gigi.

The delayed expansion is needed for nested aggregates, which the
original code is testing for, but container aggregates are handled
differently.

Such assignments to container aggregates are later transformed into
procedure calls to the procedures named in the Aggregate aspect
definition, for which the delayed expansion is not required/expected.

gcc/ada/
PR ada/118234
* exp_aggr.adb (Convert_To_Assignments): Do not mark node for
delayed expansion if parent type has the Aggregate aspect.
* sem_util.adb (Is_Container_Aggregate): Move...
* sem_util.ads (Is_Container_Aggregate): ... here and make it
public.
gcc/ada/exp_aggr.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads