Commit 6989a2bb by Ed Schonberg Committed by Pierre-Marie de Rodat

[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
parent 09825f92
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> 2018-08-21 Bob Duff <duff@adacore.com>
* einfo.ads, einfo.adb (Private_View, Shadow_Entities): Remove * einfo.ads, einfo.adb (Private_View, Shadow_Entities): Remove
......
...@@ -8754,7 +8754,6 @@ package body Sem_Ch13 is ...@@ -8754,7 +8754,6 @@ package body Sem_Ch13 is
-- Case where predicates are present -- Case where predicates are present
if Present (Expr) then if Present (Expr) then
-- Test for raise expression present -- Test for raise expression present
Test_REs (Expr); Test_REs (Expr);
...@@ -8856,6 +8855,42 @@ package body Sem_Ch13 is ...@@ -8856,6 +8855,42 @@ package body Sem_Ch13 is
Insert_After_And_Analyze (N, FBody); 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 -- within a generic unit, prevent a double analysis of the body
-- which will not be marked analyzed yet. This will happen when -- which will not be marked analyzed yet. This will happen when
-- the freeze node is created during the preanalysis of an -- the freeze node is created during the preanalysis of an
...@@ -8972,6 +9007,8 @@ package body Sem_Ch13 is ...@@ -8972,6 +9007,8 @@ package body Sem_Ch13 is
Insert_Before_And_Analyze (N, FDecl); Insert_Before_And_Analyze (N, FDecl);
Insert_After_And_Analyze (N, FBody); Insert_After_And_Analyze (N, FBody);
-- Should quantified expressions be handled here as well ???
end; end;
end if; end if;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment