From ad4e3362d3ea425d26c91c5a7d35a2649146bef9 Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Fri, 24 Jan 2014 14:51:19 +0000 Subject: sem_ch3.adb (Analyze_Declarations): At the end of an appropriate declarative part... 2014-01-24 Ed Schonberg * sem_ch3.adb (Analyze_Declarations): At the end of an appropriate declarative part, call Freeze_All from the first declaration in the scope, not from the first unfrozen one. This is necessary to apply visibility checks to entities with delayed aspects. Otherwise, in the presence of instantiations and cleanups that they may generate, the delayed aspects may be analyzed too late and produce spurious visibility errors. * sem_attr.adb: Place etype on range. * sem_ch6.adb: Documentation expression functions. From-SVN: r207039 --- gcc/ada/ChangeLog | 12 ++++++++++++ gcc/ada/sem_attr.adb | 1 + gcc/ada/sem_ch3.adb | 10 ++++++++-- gcc/ada/sem_ch6.adb | 6 +++++- 4 files changed, 26 insertions(+), 3 deletions(-) (limited to 'gcc') diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c1b5244..af31fea 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,15 @@ +2014-01-24 Ed Schonberg + + * sem_ch3.adb (Analyze_Declarations): At the end of an + appropriate declarative part, call Freeze_All from the first + declaration in the scope, not from the first unfrozen one. This + is necessary to apply visibility checks to entities with delayed + aspects. Otherwise, in the presence of instantiations and cleanups + that they may generate, the delayed aspects may be analyzed too + late and produce spurious visibility errors. + * sem_attr.adb: Place etype on range. + * sem_ch6.adb: Documentation expression functions. + 2014-01-24 Robert Dewar * exp_ch7.adb: Minor change of Indices to Indexes (preferred diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 0325287..7db09d4 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -6117,6 +6117,7 @@ package body Sem_Attr is (Low_Bound (Index), Etype (Index_Type)); Analyze_And_Resolve (High_Bound (Index), Etype (Index_Type)); + Set_Etype (Index, Etype (Index_Type)); else Analyze_And_Resolve (Index, Etype (Index_Type)); diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index c90be0c..cdfc062 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -2333,8 +2333,14 @@ package body Sem_Ch3 is Freeze_From := First_Entity (Current_Scope); end if; + -- There may have been several freezing points previously, + -- for example object declarations or subprogram bodies, but + -- at the end of a declarative part we check freezing from + -- the beginning, even though entities may already be frozen, + -- in order to perform visibility checks on delayed aspects. + Adjust_Decl; - Freeze_All (Freeze_From, Decl); + Freeze_All (First_Entity (Current_Scope), Decl); Freeze_From := Last_Entity (Current_Scope); elsif Scope (Current_Scope) /= Standard_Standard @@ -2348,7 +2354,7 @@ package body Sem_Ch3 is or else Is_Empty_List (Private_Declarations (Parent (L))) then Adjust_Decl; - Freeze_All (Freeze_From, Decl); + Freeze_All (First_Entity (Current_Scope), Decl); Freeze_From := Last_Entity (Current_Scope); end if; diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index edfaff2..ce3fcf4 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -435,7 +435,11 @@ package body Sem_Ch6 is -- To prevent premature freeze action, insert the new body at the end -- of the current declarations, or at the end of the package spec. -- However, resolve usage names now, to prevent spurious visibility - -- on later entities. + -- on later entities. Note that the function can now be called in + -- the current declarative part, which will appear to be prior to + -- the presence of the body in the code. There are nevertheless no + -- order of elaboration issues because all name resolution has taken + -- place at the point of declaration. declare Decls : List_Id := List_Containing (N); -- cgit v1.1