diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-24 15:59:23 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-24 15:59:23 +0200 |
commit | aca532984541ebca71db7cff750d36f9e25465b9 (patch) | |
tree | 96fd56588b8a31258591454a7a355551de0d5526 /gcc/ada/rtsfind.adb | |
parent | e211f8596da3e934f0894d9cc3b8637c1667acd4 (diff) | |
download | gcc-aca532984541ebca71db7cff750d36f9e25465b9.zip gcc-aca532984541ebca71db7cff750d36f9e25465b9.tar.gz gcc-aca532984541ebca71db7cff750d36f9e25465b9.tar.bz2 |
[multiple changes]
2009-04-24 Emmanuel Briot <briot@adacore.com>
* prj.adb, prj.ads, prj-nmsc.adb (Check_File, Record_Ada_Source,
Add_Source): merge some code between those. In particular change where
file normalization is done to avoid a few extra calls to
Canonicalize_File_Name. This also removes the need for passing
Current_Dir in a number of subprograms.
2009-04-24 Bob Duff <duff@adacore.com>
* lib-load.adb (Make_Instance_Unit): In the case where In_Main is
False, assign the correct unit to the Cunit field of the new table
entry. We want the spec unit, not the body unit.
* rtsfind.adb (Make_Unit_Name, Maybe_Add_With): Simplify calling
interface for these.
(Maybe_Add_With): Check whether we're trying to a with on the current
unit, and avoid creating such directly self-referential with clauses.
(Text_IO_Kludge): Add implicit with's for the generic pseudo-children of
[[Wide_]Wide_]Text_IO. These are needed for Walk_Library_Items,
and matches existing comments in the spec.
* sem.adb (Walk_Library_Items): Add various special cases to make the
assertions pass.
* sem_ch12.adb (Build_Instance_Compilation_Unit_Nodes): Use Body_Cunit
instead of Parent (N), for uniformity.
From-SVN: r146724
Diffstat (limited to 'gcc/ada/rtsfind.adb')
-rw-r--r-- | gcc/ada/rtsfind.adb | 92 |
1 files changed, 53 insertions, 39 deletions
diff --git a/gcc/ada/rtsfind.adb b/gcc/ada/rtsfind.adb index 7dbd135..986ca3a 100644 --- a/gcc/ada/rtsfind.adb +++ b/gcc/ada/rtsfind.adb @@ -164,25 +164,26 @@ package body Rtsfind is Id : RE_Id := RE_Null; Use_Setting : Boolean := False); -- Load the unit whose Id is given if not already loaded. The unit is - -- loaded, analyzed, and added to the WITH list, and the entry in - -- RT_Unit_Table is updated to reflect the load. Use_Setting is used to - -- indicate the initial setting for the Is_Potentially_Use_Visible flag of - -- the entity for the loaded unit (if it is indeed loaded). A value of - -- False means nothing special need be done. A value of True indicates that - -- this flag must be set to True. It is needed only in the Text_IO_Kludge - -- procedure, which may materialize an entity of Text_IO (or - -- [Wide_]Wide_Text_IO) that was previously unknown. Id is the RE_Id value - -- of the entity which was originally requested. Id is used only for error - -- message detail, and if it is RE_Null, then the attempt to output the - -- entity name is ignored. - - function Make_Unit_Name (E : RE_Id; N : Node_Id) return Node_Id; + -- loaded and analyzed, and the entry in RT_Unit_Table is updated to + -- reflect the load. Use_Setting is used to indicate the initial setting + -- for the Is_Potentially_Use_Visible flag of the entity for the loaded + -- unit (if it is indeed loaded). A value of False means nothing special + -- need be done. A value of True indicates that this flag must be set to + -- True. It is needed only in the Text_IO_Kludge procedure, which may + -- materialize an entity of Text_IO (or [Wide_]Wide_Text_IO) that was + -- previously unknown. Id is the RE_Id value of the entity which was + -- originally requested. Id is used only for error message detail, and if + -- it is RE_Null, then the attempt to output the entity name is ignored. + + function Make_Unit_Name + (U : RT_Unit_Table_Record; + N : Node_Id) return Node_Id; -- If the unit is a child unit, build fully qualified name for use in -- With_Clause. - procedure Maybe_Add_With (E : RE_Id; U : in out RT_Unit_Table_Record); + procedure Maybe_Add_With (U : in out RT_Unit_Table_Record); -- If necessary, add an implicit with_clause from the current unit to the - -- one represented by E and U. + -- one represented by U. procedure Output_Entity_Name (Id : RE_Id; Msg : String); -- Output continuation error message giving qualified name of entity @@ -765,9 +766,10 @@ package body Rtsfind is -- Make_Unit_Name -- -------------------- - function Make_Unit_Name (E : RE_Id; N : Node_Id) return Node_Id is - U_Id : constant RTU_Id := RE_Unit_Table (E); - U : RT_Unit_Table_Record renames RT_Unit_Table (U_Id); + function Make_Unit_Name + (U : RT_Unit_Table_Record; + N : Node_Id) return Node_Id is + Nam : Node_Id; Scop : Entity_Id; @@ -795,15 +797,24 @@ package body Rtsfind is -- Maybe_Add_With -- -------------------- - procedure Maybe_Add_With (E : RE_Id; U : in out RT_Unit_Table_Record) is + procedure Maybe_Add_With (U : in out RT_Unit_Table_Record) is Is_Main : constant Boolean := In_Extended_Main_Code_Unit (Cunit_Entity (Current_Sem_Unit)); begin -- We do not need to generate a with_clause for a call issued from - -- RTE_Component_Available. + -- RTE_Component_Available. However, for Inspector, we need these + -- additional with's, because for a sequence like "if RTE_Available (X) + -- then ... RTE (X)" the RTE call fails to create some necessary + -- with's. - if RTE_Available_Call then + if RTE_Available_Call and then not Inspector_Mode then + return; + end if; + + -- Avoid creating directly self-referential with clauses + + if Current_Sem_Unit = U.Unum then return; end if; @@ -836,7 +847,7 @@ package body Rtsfind is Make_With_Clause (Standard_Location, Name => Make_Unit_Name - (E, Defining_Unit_Name (Specification (LibUnit)))); + (U, Defining_Unit_Name (Specification (LibUnit)))); begin Set_Library_Unit (Withn, Cunit (U.Unum)); @@ -1127,7 +1138,7 @@ package body Rtsfind is end if; <<Found>> - Maybe_Add_With (E, U); + Maybe_Add_With (U); Front_End_Inlining := Save_Front_End_Inlining; return Check_CRT (E, RE_Table (E)); @@ -1229,7 +1240,7 @@ package body Rtsfind is -- If we didn't find the entity we want, something is wrong. The -- appropriate action will be taken by Check_CRT when we exit. - Maybe_Add_With (E, U); + Maybe_Add_With (U); Front_End_Inlining := Save_Front_End_Inlining; return Check_CRT (E, Found_E); @@ -1380,6 +1391,9 @@ package body Rtsfind is Name_Integer_IO => Ada_Wide_Wide_Text_IO_Integer_IO, Name_Modular_IO => Ada_Wide_Wide_Text_IO_Modular_IO); + To_Load : RTU_Id; + -- Unit to be loaded, from one of the above maps + begin -- Nothing to do if name is not an identifier or a selected component -- whose selector_name is not an identifier. @@ -1419,27 +1433,27 @@ package body Rtsfind is -- they are visible. if Name_Buffer (1 .. 12) = "a-textio.ads" then - Load_RTU - (Name_Map (Chrs), - Use_Setting => In_Use (Cunit_Entity (U))); - Set_Is_Visible_Child_Unit - (RT_Unit_Table (Name_Map (Chrs)).Entity); + To_Load := Name_Map (Chrs); elsif Name_Buffer (1 .. 12) = "a-witeio.ads" then - Load_RTU - (Wide_Name_Map (Chrs), - Use_Setting => In_Use (Cunit_Entity (U))); - Set_Is_Visible_Child_Unit - (RT_Unit_Table (Wide_Name_Map (Chrs)).Entity); + To_Load := Wide_Name_Map (Chrs); elsif Name_Buffer (1 .. 12) = "a-ztexio.ads" then - Load_RTU - (Wide_Wide_Name_Map (Chrs), - Use_Setting => In_Use (Cunit_Entity (U))); - Set_Is_Visible_Child_Unit - (RT_Unit_Table (Wide_Wide_Name_Map (Chrs)).Entity); + To_Load := Wide_Wide_Name_Map (Chrs); + + else + goto Continue; end if; + + Load_RTU + (To_Load, + Use_Setting => In_Use (Cunit_Entity (U))); + Set_Is_Visible_Child_Unit + (RT_Unit_Table (To_Load).Entity); + Maybe_Add_With (RT_Unit_Table (To_Load)); end if; + + <<Continue>> null; end loop; end if; |