[Ada] Compiler crash on sliding of fixed-lower-bound object in Loop_Invariant

gcc/ada/

	* exp_util.adb (Expand_Sliding_Conversion): Only perform
	expansion when Expander_Active is True. Add a comment about this
	and refine existing comment regarding string literals.
This commit is contained in:
Gary Dismukes 2021-03-25 13:37:58 -04:00 committed by Pierre-Marie de Rodat
parent c9fcf01172
commit eb077d7047
1 changed files with 8 additions and 3 deletions

View File

@ -5343,10 +5343,15 @@ package body Exp_Util is
All_FLBs_Match : Boolean := True; All_FLBs_Match : Boolean := True;
begin begin
-- Sliding should never be needed for string literals, because they have -- This procedure is called during semantic analysis, and we only expand
-- their bounds set according to the applicable index constraint. -- a sliding conversion when Expander_Active, to avoid doing it during
-- preanalysis (which can lead to problems with the target subtype not
-- getting properly expanded during later full analysis). Also, sliding
-- should never be needed for string literals, because their bounds are
-- determined directly based on the fixed lower bound of Arr_Typ and
-- their length.
if Nkind (N) /= N_String_Literal then if Expander_Active and then Nkind (N) /= N_String_Literal then
Constraints := New_List; Constraints := New_List;
Act_Subt := Get_Actual_Subtype (N); Act_Subt := Get_Actual_Subtype (N);