diff options
author | Marc Poulhiès <poulhies@adacore.com> | 2023-03-27 16:47:04 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-29 10:23:20 +0200 |
commit | 8196b58e0a1a466a41d2fd2f3c6eb3f6ee68685c (patch) | |
tree | 1acd91609d94cfa01603511af1979b096c70e753 /gcc/ada/sem_util.ads | |
parent | f8bf6ae4cf087a9947c431a06f77104fa20ae36f (diff) | |
download | gcc-8196b58e0a1a466a41d2fd2f3c6eb3f6ee68685c.zip gcc-8196b58e0a1a466a41d2fd2f3c6eb3f6ee68685c.tar.gz gcc-8196b58e0a1a466a41d2fd2f3c6eb3f6ee68685c.tar.bz2 |
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.
Diffstat (limited to 'gcc/ada/sem_util.ads')
-rw-r--r-- | gcc/ada/sem_util.ads | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index b5bcd26..d1bbc6a 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1475,6 +1475,9 @@ package Sem_Util is -- Return True if the loop has no side effect and can therefore be -- marked for removal. Return False if N is not a N_Loop_Statement. + function Is_Container_Aggregate (Exp : Node_Id) return Boolean; + -- Is the given expression a container aggregate? + function Is_Newly_Constructed (Exp : Node_Id; Context_Requires_NC : Boolean) return Boolean; -- Indicates whether a given expression is "newly constructed" (RM 4.4). |