aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-08-21 14:47:50 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-08-21 14:47:50 +0000
commit6989a2bbfa259633296bf1e9f278ea83c5345811 (patch)
tree13f055352de3eb952d2701efd3c782195942d2cc
parent09825f923fadac7b79a894c4e7f6e0839c2837ac (diff)
downloadgcc-6989a2bbfa259633296bf1e9f278ea83c5345811.zip
gcc-6989a2bbfa259633296bf1e9f278ea83c5345811.tar.gz
gcc-6989a2bbfa259633296bf1e9f278ea83c5345811.tar.bz2
[Ada] Fix scope computation for loop statements
2018-08-21 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_ch13.adb (Build_Predicate_Functioss): Apply Reset_Quantified_Variables_Scope after predicate function has been analyzed, so that the scope can be reset on the generated loop statements that have replaced the quantified expressions. From-SVN: r263729
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/sem_ch13.adb39
2 files changed, 45 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index a89911a..48974e7 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2018-08-21 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch13.adb (Build_Predicate_Functioss): Apply
+ Reset_Quantified_Variables_Scope after predicate function has
+ been analyzed, so that the scope can be reset on the generated
+ loop statements that have replaced the quantified expressions.
+
2018-08-21 Bob Duff <duff@adacore.com>
* einfo.ads, einfo.adb (Private_View, Shadow_Entities): Remove
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 28a3dd8..1a12622 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -8754,7 +8754,6 @@ package body Sem_Ch13 is
-- Case where predicates are present
if Present (Expr) then
-
-- Test for raise expression present
Test_REs (Expr);
@@ -8856,6 +8855,42 @@ package body Sem_Ch13 is
Insert_After_And_Analyze (N, FBody);
+ -- The defining identifier of a quantified expression carries the
+ -- scope in which the type appears, but when unnesting we need
+ -- to indicate that its proper scope is the constructed predicate
+ -- function. The quantified expressions have been converted into
+ -- loops during analysis and expansion.
+
+ declare
+ function Reset_Quantified_Variable_Scope (N : Node_Id)
+ return Traverse_Result;
+
+ procedure Reset_Quantified_Variables_Scope is
+ new Traverse_Proc (Reset_Quantified_Variable_Scope);
+
+ -------------------------------------
+ -- Reset_Quantified_Variable_Scope --
+ -------------------------------------
+
+ function Reset_Quantified_Variable_Scope (N : Node_Id)
+ return Traverse_Result
+ is
+ begin
+ if Nkind_In (N, N_Iterator_Specification,
+ N_Loop_Parameter_Specification)
+ then
+ Set_Scope (Defining_Identifier (N),
+ Predicate_Function (Typ));
+ end if;
+ return OK;
+ end Reset_Quantified_Variable_Scope;
+
+ begin
+ if Unnest_Subprogram_Mode then
+ Reset_Quantified_Variables_Scope (Expr);
+ end if;
+ end;
+
-- within a generic unit, prevent a double analysis of the body
-- which will not be marked analyzed yet. This will happen when
-- the freeze node is created during the preanalysis of an
@@ -8972,6 +9007,8 @@ package body Sem_Ch13 is
Insert_Before_And_Analyze (N, FDecl);
Insert_After_And_Analyze (N, FBody);
+
+ -- Should quantified expressions be handled here as well ???
end;
end if;