sem_ch3.adb (Analyze_Declarations): At the end of an appropriate declarative part...
authorEd Schonberg <schonberg@adacore.com>
Fri, 24 Jan 2014 14:51:19 +0000 (14:51 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 24 Jan 2014 14:51:19 +0000 (15:51 +0100)
2014-01-24  Ed Schonberg  <schonberg@adacore.com>

* 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
gcc/ada/sem_attr.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch6.adb

index c1b5244..af31fea 100644 (file)
@@ -1,3 +1,15 @@
+2014-01-24  Ed Schonberg  <schonberg@adacore.com>
+
+       * 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  <dewar@adacore.com>
 
        * exp_ch7.adb: Minor change of Indices to Indexes (preferred
index 0325287..7db09d4 100644 (file)
@@ -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));
index c90be0c..cdfc062 100644 (file)
@@ -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;
 
index edfaff2..ce3fcf4 100644 (file)
@@ -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);