aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-07-31 11:54:35 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-07-31 11:54:35 +0200
commit33ca28671fdf5505026312d4b01e807a768d8178 (patch)
tree905043e449a5ae3ab26d86e35ecc96777d634001 /gcc
parent0407af53dd36c25bf4dbbc18f2e8f4d1cf0b7092 (diff)
downloadgcc-33ca28671fdf5505026312d4b01e807a768d8178.zip
gcc-33ca28671fdf5505026312d4b01e807a768d8178.tar.gz
gcc-33ca28671fdf5505026312d4b01e807a768d8178.tar.bz2
[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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/freeze.adb27
-rw-r--r--gcc/ada/sem_ch5.adb28
3 files changed, 51 insertions, 10 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 444aed2..d8f1bbb 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 99464b8..fb1b904 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -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))
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index a961bb7..8bf9df7 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -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