summaryrefslogtreecommitdiff
path: root/gcc/ada/sem.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-20 10:18:00 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-06-20 10:18:00 +0000
commit0754d6dd450e502e819e2a771afb9444bd5b630d (patch)
tree2e35a5c020bdbd241e21cc8385d6b296866e998d /gcc/ada/sem.adb
parentc2abd8e49c515318f9d2d5896512be0d7065778e (diff)
downloadgcc-0754d6dd450e502e819e2a771afb9444bd5b630d.tar.gz
2009-06-20 Ed Schonberg <schonberg@adacore.com>
* sem.adb (Walk_Library_Units): Check instantiations first. * sem_ch6.adb (Analyze_Subprogram_Declaration): Mark a subprogram as a private primitive if it is a function with a controlling result that is a type extension with progenitors. * exp_ch9.adb (Build_Wrapper_Spec, Build_Wrapper_Body): Handle properly a primitive operation of a synchronized tagged type that has a controlling result. 2009-06-20 Thomas Quinot <quinot@adacore.com> * einfo.ads: Fix typo. 2009-06-20 Ed Falis <falis@adacore.com> * s-vxwext.ads, s-vxwext-kernel.adb: Complete previous change. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148743 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem.adb')
-rw-r--r--gcc/ada/sem.adb57
1 files changed, 27 insertions, 30 deletions
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb
index 58521e9c727..dad352b03d4 100644
--- a/gcc/ada/sem.adb
+++ b/gcc/ada/sem.adb
@@ -1766,6 +1766,10 @@ package body Sem is
Do_Action (Empty, Standard_Package_Node);
+ -- First place the context of all instance bodies on the corresponding
+ -- spec, because it may be needed to analyze the code at the place of
+ -- the instantiation.
+
Cur := First_Elmt (Comp_Unit_List);
while Present (Cur) loop
declare
@@ -1773,43 +1777,36 @@ package body Sem is
N : constant Node_Id := Unit (CU);
begin
- pragma Assert (Nkind (CU) = N_Compilation_Unit);
-
- case Nkind (N) is
+ if Nkind (N) = N_Package_Body
+ and then Is_Generic_Instance (Defining_Entity (N))
+ then
+ Append_List
+ (Context_Items (CU), Context_Items (Library_Unit (CU)));
+ end if;
- -- If it's a body, then ignore it, unless it's an instance (in
- -- which case we do the spec), or it's the main unit (in which
- -- case we do it). Note that it could be both, in which case we
- -- do the with_clauses of spec and body first,
+ Next_Elmt (Cur);
+ end;
+ end loop;
- when N_Package_Body | N_Subprogram_Body =>
- declare
- Entity : Node_Id := N;
+ -- Now traverse compilation units in order.
- begin
- if Nkind (Entity) = N_Subprogram_Body then
- Entity := Specification (Entity);
- end if;
+ Cur := First_Elmt (Comp_Unit_List);
+ while Present (Cur) loop
+ declare
+ CU : constant Node_Id := Node (Cur);
+ N : constant Node_Id := Unit (CU);
- Entity := Defining_Entity (Entity);
+ begin
+ pragma Assert (Nkind (CU) = N_Compilation_Unit);
- if Is_Generic_Instance (Entity) then
- declare
- Spec_Unit : constant Node_Id := Library_Unit (CU);
+ case Nkind (N) is
- begin
- -- Move context of body to that of spec, so it
- -- appears before the spec itself, in case it
- -- contains nested instances that generate late
- -- with_clauses that got attached to the body.
+ -- If it's a body, then ignore it, unless it's the main unit
+ -- Otherwise bodies appear in the list because of inlining or
+ -- instantiations, and they are processed immediately after
+ -- the corresponding specs.
- Append_List
- (Context_Items (CU), Context_Items (Spec_Unit));
- Do_Unit_And_Dependents
- (Spec_Unit, Unit (Spec_Unit));
- end;
- end if;
- end;
+ when N_Package_Body | N_Subprogram_Body =>
if CU = Cunit (Main_Unit) then
Do_Unit_And_Dependents (CU, N);