summaryrefslogtreecommitdiff
path: root/gcc/ada/sem.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-09 12:37:05 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-09 12:37:05 +0000
commitfb3e33e4de2f3d0632c30d29fdc417f25360c671 (patch)
tree0eaeed3aaa3182cf44357a7cc4257133d48d651b /gcc/ada/sem.adb
parent56a442818e1d62f15e4d94b87cf3e59295f9b528 (diff)
downloadgcc-fb3e33e4de2f3d0632c30d29fdc417f25360c671.tar.gz
2010-09-09 Ed Schonberg <schonberg@adacore.com>
* sem.adb (Walk_Library_Items): Traverse context of subunits of the main unit. (Is_Subunit_Of_Main): Handle null nodes properly. 2010-09-09 Robert Dewar <dewar@adacore.com> * par-ch2.adb: Update comments. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164083 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem.adb')
-rw-r--r--gcc/ada/sem.adb36
1 files changed, 34 insertions, 2 deletions
diff --git a/gcc/ada/sem.adb b/gcc/ada/sem.adb
index 2955b1c9d69..d3d07cb74a7 100644
--- a/gcc/ada/sem.adb
+++ b/gcc/ada/sem.adb
@@ -1985,15 +1985,47 @@ package body Sem is
if not Done (Main_Unit) then
Do_Main := True;
- declare
+ Process_Main : declare
Parent_CU : Node_Id;
Body_CU : Node_Id;
Body_U : Unit_Number_Type;
Child : Entity_Id;
+ function Is_Subunit_Of_Main (U : Node_Id) return Boolean;
+ -- If the main unit has subunits, their context may include
+ -- bodies that are needed in the body of main. We must examine
+ -- the context of the subunits, which are otherwise not made
+ -- explicit in the main unit.
+
+ ------------------------
+ -- Is_Subunit_Of_Main --
+ ------------------------
+
+ function Is_Subunit_Of_Main (U : Node_Id) return Boolean is
+ Lib : Node_Id;
+ begin
+ if No (U) then
+ return False;
+ else
+ Lib := Library_Unit (U);
+ return Nkind (Unit (U)) = N_Subunit
+ and then
+ (Lib = Cunit (Main_Unit)
+ or else Is_Subunit_Of_Main (Lib));
+ end if;
+ end Is_Subunit_Of_Main;
+
+ -- Start of processing for Process_Main
+
begin
Process_Bodies_In_Context (Main_CU);
+ for Unit_Num in Done'Range loop
+ if Is_Subunit_Of_Main (Cunit (Unit_Num)) then
+ Process_Bodies_In_Context (Cunit (Unit_Num));
+ end if;
+ end loop;
+
-- If the main unit is a child unit, parent bodies may be present
-- because they export instances or inlined subprograms. Check for
-- presence of these, which are not present in context clauses.
@@ -2023,7 +2055,7 @@ package body Sem is
Do_Action (Main_CU, Unit (Main_CU));
Done (Main_Unit) := True;
- end;
+ end Process_Main;
end if;
if Debug_Unit_Walk then