+2014-07-31 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * freeze.adb (Freeze_Expression): Update the loop in charge
+ of finding a proper insertion place for freeze nodes to handle
+ N_Expression_With_Actions nodes.
+
2014-07-31 Robert Dewar <dewar@adacore.com>
* sem_util.adb, a-ngelfu.ads, prj-nmsc.adb, prj-conf.adb: Minor
exit when Is_List_Member (P);
- -- Note: The N_Loop_Statement is a special case. A type that
- -- appears in the source can never be frozen in a loop (this
- -- occurs only because of a loop expanded by the expander), so we
- -- keep on going. Otherwise we terminate the search. Same is true
- -- of any entity which comes from source. (if they have predefined
- -- type, that type does not appear to come from source, but the
- -- entity should not be frozen here).
+ -- Freeze nodes produced by an expression coming from the Actions
+ -- list of a N_Expression_With_Actions node must remain within the
+ -- Actions list. Inserting the freeze nodes further up the tree
+ -- may lead to use before declaration issues in the case of array
+ -- types.
+
+ when N_Expression_With_Actions =>
+ if Is_List_Member (P)
+ and then List_Containing (P) = Actions (Parent_P)
+ then
+ exit;
+ end if;
+
+ -- Note: N_Loop_Statement is a special case. A type that appears
+ -- in the source can never be frozen in a loop (this occurs only
+ -- because of a loop expanded by the expander), so we keep on
+ -- going. Otherwise we terminate the search. Same is true of any
+ -- entity which comes from source. (if they have predefined type,
+ -- that type does not appear to come from source, but the entity
+ -- should not be frozen here).
when N_Loop_Statement =>
exit when not Comes_From_Source (Etype (N))
and then not ASIS_Mode
then
declare
- Id : constant Entity_Id := Make_Temporary (Loc, 'R', Iter_Name);
- Decl : Node_Id;
+ Id : constant Entity_Id := Make_Temporary (Loc, 'R', Iter_Name);
+ Decl : Node_Id;
+ Act_S : Node_Id;
begin
- Typ := Etype (Iter_Name);
+
+ -- If the domain of iteration is an array component that depends
+ -- on a discriminant, create actual subtype for it. Pre-analysis
+ -- does not generate the actual subtype of a selected component.
+
+ if Nkind (Iter_Name) = N_Selected_Component
+ and then Is_Array_Type (Etype (Iter_Name))
+ then
+ Act_S :=
+ Build_Actual_Subtype_Of_Component
+ (Etype (Selector_Name (Iter_Name)), Iter_Name);
+ Insert_Action (N, Act_S);
+
+ if Present (Act_S) then
+ Typ := Defining_Identifier (Act_S);
+ else
+ Typ := Etype (Iter_Name);
+ end if;
+
+ else
+ Typ := Etype (Iter_Name);
+ end if;
-- Protect against malformed iterator