ada: Fix crash on vector initialization
commit8196b58e0a1a466a41d2fd2f3c6eb3f6ee68685c
authorMarc Poulhiès <poulhies@adacore.com>
Mon, 27 Mar 2023 14:47:04 +0000 (27 16:47 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 29 May 2023 08:23:20 +0000 (29 10:23 +0200)
tree1acd91609d94cfa01603511af1979b096c70e753
parentf8bf6ae4cf087a9947c431a06f77104fa20ae36f
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/

* 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