[multiple changes]

2014-07-31  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch5.adb (Analyze_Iterator_Specification): If the domain of
	iteration is an array component that depends on discriminants,
	create an actual subtype for it, because the preanalysis of the
	iterator name does not create actual subtypes of components.

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.

From-SVN: r213333
This commit is contained in:
Arnaud Charlet 2014-07-31 11:54:35 +02:00
parent 0407af53dd
commit 33ca28671f
3 changed files with 51 additions and 10 deletions

View File

@ -1,3 +1,9 @@
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

View File

@ -6143,13 +6143,26 @@ package body Freeze is
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))

View File

@ -1750,11 +1750,33 @@ package body Sem_Ch5 is
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