aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch12.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-08-31 11:07:20 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2011-08-31 11:07:20 +0200
commit8cf23b91885b80e1f673cbc4135d01390b65d213 (patch)
tree51ba512577c9b4202ce015f57c761ef8d3020acb /gcc/ada/sem_ch12.adb
parent0bb3bfb8feacd4bec3f0dc82d75cf1ea01d37010 (diff)
downloadgcc-8cf23b91885b80e1f673cbc4135d01390b65d213.zip
gcc-8cf23b91885b80e1f673cbc4135d01390b65d213.tar.gz
gcc-8cf23b91885b80e1f673cbc4135d01390b65d213.tar.bz2
[multiple changes]
2011-08-31 Robert Dewar <dewar@adacore.com> * exp_ch5.adb, exp_alfa.ads, prj.ads, sem_attr.adb, lib-xref-alfa.adb: Minor reformatting. 2011-08-31 Matthew Heaney <heaney@adacore.com> * a-crbltr.ads (Tree_Type): Default-initialize the Nodes component. 2011-08-31 Javier Miranda <miranda@adacore.com> * sem_ch4.adb (Try_Object_Operation): Addition of one formal to search only for class-wide subprograms conflicting with entities of concurrent tagged types. 2011-08-31 Matthew Heaney <heaney@adacore.com> * a-rbtgbo.adb (Generic_Allocate): Initialize pointer components of node to null value. 2011-08-31 Hristian Kirtchev <kirtchev@adacore.com> * sem_ch12.adb (Insert_Freeze_Node_For_Instance): Provide a more general description of the routine. 2011-08-31 Ed Schonberg <schonberg@adacore.com> * a-cbdlli.adb, a-cbdlli.ads: Add iterator machinery to bounded doubly-linked lists. From-SVN: r178363
Diffstat (limited to 'gcc/ada/sem_ch12.adb')
-rw-r--r--gcc/ada/sem_ch12.adb44
1 files changed, 29 insertions, 15 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index ad6d482..d759def 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -519,19 +519,11 @@ package body Sem_Ch12 is
procedure Insert_Freeze_Node_For_Instance
(N : Node_Id;
F_Node : Node_Id);
- -- N is an instance and F_Node is its corresponding freeze node. Insert
- -- F_Node depending on the enclosing context and placement of N in the
- -- following manner:
- --
- -- 1) N is a package instance - Attempt to insert the freeze node before
- -- a source package or subprogram body which follows immediately after N.
- -- If no such body is found, perform the actions in 2).
- --
- -- 2) N is a subprogram instance or a package instance not followed by
- -- a source body - Insert the freeze node at the end of the declarations
- -- list which contains N. If N is in the visible part of an enclosing
- -- package declaration, the freeze node is inserted at the end of the
- -- private declarations.
+ -- N denotes a package or a subprogram instantiation and F_Node is the
+ -- associated freeze node. Insert the freeze node before the first source
+ -- body which follows immediately after N. If no such body is found, the
+ -- freeze node is inserted at the end of the declarative region which
+ -- contains N.
procedure Freeze_Subprogram_Body
(Inst_Node : Node_Id;
@@ -7586,7 +7578,6 @@ package body Sem_Ch12 is
elsif Nkind (Parent (N)) = N_Package_Body
and then In_Same_Declarative_Part (Freeze_Node (Par), Parent (N))
then
-
declare
Enclosing : constant Entity_Id :=
Corresponding_Spec (Parent (N));
@@ -7596,7 +7587,30 @@ package body Sem_Ch12 is
Ensure_Freeze_Node (Enclosing);
if not Is_List_Member (Freeze_Node (Enclosing)) then
- Insert_After (Freeze_Node (Par), Freeze_Node (Enclosing));
+
+ -- The enclosing context is a subunit, insert the freeze
+ -- node after the stub.
+
+ if Nkind (Parent (Parent (N))) = N_Subunit then
+ Insert_Freeze_Node_For_Instance
+ (Corresponding_Stub (Parent (Parent (N))),
+ Freeze_Node (Enclosing));
+
+ -- The parent instance has been frozen before the body of
+ -- the enclosing package, insert the freeze node after
+ -- the body.
+
+ elsif List_Containing (Freeze_Node (Par)) =
+ List_Containing (Parent (N))
+ and then Sloc (Freeze_Node (Par)) < Sloc (Parent (N))
+ then
+ Insert_Freeze_Node_For_Instance
+ (Parent (N), Freeze_Node (Enclosing));
+
+ else
+ Insert_After
+ (Freeze_Node (Par), Freeze_Node (Enclosing));
+ end if;
end if;
end;