From: Ed Schonberg Date: Tue, 21 Aug 2018 14:47:50 +0000 (+0000) Subject: [Ada] Fix scope computation for loop statements X-Git-Tag: upstream/12.2.0~29663 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6989a2bbfa259633296bf1e9f278ea83c5345811;p=platform%2Fupstream%2Fgcc.git [Ada] Fix scope computation for loop statements 2018-08-21 Ed Schonberg 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 --- 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 + + * 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 * 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;