Declarations => New_List (Init_Decl),
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
- Statements => New_List (New_Loop))));
+ Statements => Empty_List)));
-- The loop parameter is declared by an object declaration (Init_Decl),
-- but within the loop we must prevent user assignments to it, so we
-- analyze Init_Decl and reset the entity kind, before analyzing the
- -- rest of the loop. First Preanalyze the block statement, to set its
- -- Identifier, and then push that as the scope in which to analyze
- -- Init_Decl.
+ -- rest of the loop. First Preanalyze the (empty) block statement,
+ -- to set its Identifier, and then push that as the scope in which
+ -- to analyze Init_Decl. Fill in the Statements after preanalysis;
+ -- otherwise we incorrectly duplicate whatever temps are created
+ -- for the loop.
Preanalyze (N);
Push_Scope (Entity (Identifier (N)));
+ Set_Statements (Handled_Statement_Sequence (N), New_List (New_Loop));
Analyze (Init_Decl);
Init_Name := Defining_Identifier (Init_Decl);