aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sinfo.adb
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2020-05-17 21:02:59 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-07-08 10:55:51 -0400
commitff49b8053d16b0a565a02400ac0db81e5fd8f2cd (patch)
tree51744f051e71fbe19f3f25b6c35d31195cf7f21d /gcc/ada/sinfo.adb
parentc1fece377a93b1809243280fcbe01b143f105c9c (diff)
downloadgcc-ff49b8053d16b0a565a02400ac0db81e5fd8f2cd.zip
gcc-ff49b8053d16b0a565a02400ac0db81e5fd8f2cd.tar.gz
gcc-ff49b8053d16b0a565a02400ac0db81e5fd8f2cd.tar.bz2
[Ada] Ada_2020 AI12-0250 : Implement Iterator filters.
gcc/ada/ * par.adb (P_Iterator_Specification): Make public for use in other parser subprograms. * par-ch4.adb (P_Iterated_Component_Association): In Ada_2020, recognize use of Iterator_Specification in an element iterator. To simplify disambiguation between the two iterator forms, mark the component association as carrying an Iterator_Specification only when the element iterator (using "OF") is used. * par-ch5.adb (P_Loop_Parameter_Specification): In Ada_2020, parse iterator filter when present. (P_Iterator_Specification): Ditto. Remove declaration of P_Iterator_Specification, now in parent unit. * exp_ch5.adb (Expand_N_Loop_Statement): Apply Iterator filter when present. (Expand_Iterator_Loop_Over_Array): Ditto. (Expand_Iterator_Loop_Over_Container): Ditto. * sem_aggr.adb (Resolve_Array_Aggregate): Emit error nessage if an iterated component association includes a iterator specificcation with an element iterator, i.e. one that uses the OF keyword. * sem_ch5.adb (Analyze_Iterator_Specification): Analyze Iterator filter when present. (Analyze_Loop_Parameter_Specification): Ditto. * sinfo.adb: Suprogram bodies for new syntactic element Iterator_Filter. * sinfo.ads: Add Iterator_Filter to relevant nodes. Structure of Component_Association and Iteroted_Component_Association nodes is modified to take into account the possible presence of an iterator specification in the latter.
Diffstat (limited to 'gcc/ada/sinfo.adb')
-rw-r--r--gcc/ada/sinfo.adb24
1 files changed, 22 insertions, 2 deletions
diff --git a/gcc/ada/sinfo.adb b/gcc/ada/sinfo.adb
index 7368db6..7284a06 100644
--- a/gcc/ada/sinfo.adb
+++ b/gcc/ada/sinfo.adb
@@ -2223,6 +2223,15 @@ package body Sinfo is
return Flag5 (N);
end Is_Write;
+ function Iterator_Filter
+ (N : Node_Id) return Node_Id is
+ begin
+ pragma Assert (False
+ or else NT (N).Nkind = N_Iterator_Specification
+ or else NT (N).Nkind = N_Loop_Parameter_Specification);
+ return Node3 (N);
+ end Iterator_Filter;
+
function Iteration_Scheme
(N : Node_Id) return Node_Id is
begin
@@ -2235,6 +2244,7 @@ package body Sinfo is
(N : Node_Id) return Node_Id is
begin
pragma Assert (False
+ or else NT (N).Nkind = N_Iterated_Component_Association
or else NT (N).Nkind = N_Iteration_Scheme
or else NT (N).Nkind = N_Quantified_Expression);
return Node2 (N);
@@ -2358,7 +2368,7 @@ package body Sinfo is
pragma Assert (False
or else NT (N).Nkind = N_Component_Association
or else NT (N).Nkind = N_Iterated_Component_Association);
- return List2 (N);
+ return List5 (N);
end Loop_Actions;
function Loop_Parameter_Specification
@@ -5700,6 +5710,15 @@ package body Sinfo is
Set_Flag5 (N, Val);
end Set_Is_Write;
+ procedure Set_Iterator_Filter
+ (N : Node_Id; Val : Node_Id) is
+ begin
+ pragma Assert (False
+ or else NT (N).Nkind = N_Iterator_Specification
+ or else NT (N).Nkind = N_Loop_Parameter_Specification);
+ Set_Node3_With_Parent (N, Val);
+ end Set_Iterator_Filter;
+
procedure Set_Iteration_Scheme
(N : Node_Id; Val : Node_Id) is
begin
@@ -5712,6 +5731,7 @@ package body Sinfo is
(N : Node_Id; Val : Node_Id) is
begin
pragma Assert (False
+ or else NT (N).Nkind = N_Iterated_Component_Association
or else NT (N).Nkind = N_Iteration_Scheme
or else NT (N).Nkind = N_Quantified_Expression);
Set_Node2_With_Parent (N, Val);
@@ -5835,7 +5855,7 @@ package body Sinfo is
pragma Assert (False
or else NT (N).Nkind = N_Component_Association
or else NT (N).Nkind = N_Iterated_Component_Association);
- Set_List2 (N, Val); -- semantic field, no parent set
+ Set_List5 (N, Val); -- semantic field, no parent set
end Set_Loop_Actions;
procedure Set_Loop_Parameter_Specification