diff options
author | Gary Dismukes <dismukes@adacore.com> | 2024-02-12 20:18:36 +0000 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-14 10:19:55 +0200 |
commit | a9714dce8245f87c937a8fdef52db15ca6571525 (patch) | |
tree | 4bd62aeb931566e695bc9e9e327c400255af624e | |
parent | fb48b0aa2faf88897fb0110026e80dfa1a59056f (diff) | |
download | gcc-a9714dce8245f87c937a8fdef52db15ca6571525.zip gcc-a9714dce8245f87c937a8fdef52db15ca6571525.tar.gz gcc-a9714dce8245f87c937a8fdef52db15ca6571525.tar.bz2 |
ada: Compiler crash or errors on if_expression in container aggregate
The compiler may either crash or incorrectly report errors when
a component association in a container aggregate is an if_expression
with an elsif part whose dependent expression is a call to a function
returning a result that requires finalization. The compiler complains
that a private type is expected, but a package or procedure name was
found. This is due to the compiler improperly associating expanded
calls to Finalize_Object with the aggregate, rather than the enclosing
object declaration being initialized by the aggregate, which can result
in the Finalize_Object procedure call being passed as an actual to
the Add_Unnamed operation of the container type and leading to a type
mismatch and the confusing error message. This is fixed by adjusting
the code that locates the proper context for insertion of Finalize_Object
calls to locate the enclosing declaration or statement rather than
stopping at the aggregate.
gcc/ada/
* exp_util.adb (Find_Hook_Context): Exclude N_*Aggregate Nkinds
of Parent (Par) from the early return in the second loop of the
In_Cond_Expr case, to prevent returning an aggregate from this
function rather than the enclosing declaration or statement.
-rw-r--r-- | gcc/ada/exp_util.adb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 4b1c532..d9623e2 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -6412,7 +6412,9 @@ package body Exp_Util is and then Nkind (Parent (Par)) not in N_Function_Call | N_Procedure_Call_Statement | N_Entry_Call_Statement - + | N_Aggregate + | N_Delta_Aggregate + | N_Extension_Aggregate then return Par; |