Skip to content

Commit

Permalink
ada: Compiler hangs on container aggregate with function call as key …
Browse files Browse the repository at this point in the history
…expression

The compiler hangs (or may crash, if assertions are enabled) when compiling
an iterated association of a container aggregate that has a key expression
given by a function call. The resolution of the call leads to a blowup in
Build_Call_Marker, because the temporary copy of the expression that's
analyzed has an Empty parent, causing insertion of the call marker to fail.
The fix for this is to preanalyze, rather than analyze, the copy of the key
expression (Build_Call_Marker will return without creating a call marker in
the case of preanalysis).

gcc/ada/

	* sem_aggr.adb (Resolve_Iterated_Association): Call
	Preanalyze_And_Resolve instead of Analyze_And_Resolve on a key
	expression of an iterated association.

Tested on x86_64-pc-linux-gnu, committed on master.
  • Loading branch information
dismukes authored and ouuleilei-bot committed Dec 19, 2023
1 parent c2d62cd commit 1651a58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcc/ada/sem_aggr.adb
Original file line number Diff line number Diff line change
Expand Up @@ -3060,13 +3060,13 @@ package body Sem_Aggr is
(Iterator_Specification (Comp)));
end if;

-- Key expression must have the type of the key. We analyze
-- Key expression must have the type of the key. We preanalyze
-- a copy of the original expression, because it will be
-- reanalyzed and copied as needed during expansion of the
-- corresponding loop.

Key_Expr := Key_Expression (Comp);
Analyze_And_Resolve (New_Copy_Tree (Key_Expr), Key_Type);
Preanalyze_And_Resolve (New_Copy_Tree (Key_Expr), Key_Type);
End_Scope;

elsif Present (Iterator_Specification (Comp)) then
Expand Down

0 comments on commit 1651a58

Please sign in to comment.