In the case of an aggregate containing controlled array components, if sliding of the indexes is involved, the components are prematurely finalized without a corresponding initialization. Also fix a latent bug in Exp_Aggr.Collect_Initialization_Statements which was not always inserting Initialization_Statements properly when the Node_After was empty (in the case of e.g. a single object declaration). This is needed in order to take advantage of Initialization_Statements in Expand_N_Object_Declaration: we scan Initialization_Statements and if a call to xxxSA is found, it means we need to initialize the corresponding array component before it gets prematurely adjusted. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_aggr.adb (Collect_Initialization_Statements): Removed. (Convert_Aggr_In_Object_Decl, Expand_Array_Aggregate): Fix creation and insertion of Initialization_Statements. Do not set Initialization_Statements when a transient scope is involved. Move processing of Array_Slice here. Ensure that an object with an Array_Slice call gets its array component initialized. Add comments. * exp_ch7.adb: Update comments. (Store_Actions_In_Scope): Deal properly with an empty list which might now be generated by Convert_Aggr_In_Object_Decl. * exp_ch3.adb: Update comments. (Expand_N_Object_Declaration): Remove processing of Array_Slice.