Skip to content
Snippets Groups Projects
Commit a9714dce authored by Gary Dismukes's avatar Gary Dismukes Committed by Marc Poulhiès
Browse files

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.
parent fb48b0aa
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment