diff options
author | Hristian Kirtchev <kirtchev@adacore.com> | 2018-01-11 08:51:13 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-01-11 08:51:13 +0000 |
commit | 94ce49419aef75f3414edcaeba89e63c6c3be320 (patch) | |
tree | 57ecfd78c9e0afab4a505645053aa796cd2a059b /gcc/ada/lib-writ.adb | |
parent | 775192706061030d927945619d3a41c5825e455d (diff) | |
download | gcc-94ce49419aef75f3414edcaeba89e63c6c3be320.tar.gz |
[Ada] Encoding of with clauses in ALI files
This patch modifies the encodings of with clauses in ALI files to adhere to the
existing API. The encodigs are as follows:
* Explicit with clauses are encoded on a 'W' line (same as before).
* Implicit with clauses for ancestor units are encoded on a 'W' line (same
as before).
* Limited_with clauses are encoded on a 'Y' line (same as before).
* ABE and RTSfind-related with clauses are encoded on a 'Z' line.
------------
-- Source --
------------
-- case_10_func.adb
function Case_10_Func return Boolean is
begin
return True;
end Case_10_Func;
-- case_10_gen_func.ads
generic
function Case_10_Gen_Func return Boolean;
-- case_10_gen_func.adb
function Case_10_Gen_Func return Boolean is
begin
return True;
end Case_10_Gen_Func;
-- case_10_tasks.ads
package Case_10_Tasks is
task type Task_Typ is
end Task_Typ;
end Case_10_Tasks;
-- case_10_tasks.adb
package body Case_10_Tasks is
task body Task_Typ is begin null; end Task_Typ;
end Case_10_Tasks;
-- case_10_gen.ads
with Case_10_Func;
with Case_10_Gen_Func;
with Case_10_Tasks;
generic
package Case_10_Gen is
Val : constant Boolean := Case_10_Func;
function Inst is new Case_10_Gen_Func;
Tsk : Case_10_Tasks.Task_Typ;
end Case_10_Gen;
-- case_10.ads
with Case_10_Gen;
package Case_10 is
package Inst is new Case_10_Gen;
end Case_10;
----------------------------
-- Compilation and output --
----------------------------
$ gcc -c case_10.ads
$ grep "W " case_10.ali | sort
$ grep "Z " case_10.ali | sort
W case_10_gen%s case_10_gen.ads case_10_gen.ali
Z case_10_func%b case_10_func.adb case_10_func.ali
Z case_10_gen_func%s case_10_gen_func.adb case_10_gen_func.ali ED
Z case_10_tasks%s case_10_tasks.adb case_10_tasks.ali AD
Z system.soft_links%s s-soflin.adb s-soflin.ali
Z system.tasking%s s-taskin.adb s-taskin.ali
Z system.tasking.stages%s s-tassta.adb s-tassta.ali
2018-01-11 Hristian Kirtchev <kirtchev@adacore.com>
gcc/ada/
* ali.adb: Document the remaining letters available for ALI lines.
(Scan_ALI): A with clause is internal when it is encoded on a 'Z' line.
* ali.ads: Update type With_Record. Field
Implicit_With_From_Instantiation is no longer in use. Add field
Implicit_With.
* csinfo.adb (CSinfo): Remove the setup for attribute
Implicit_With_From_Instantiation.
* lib-writ.adb (Collect_Withs): Correct the logic which marks a unit as
either implicitly or explicitly withed.
(Is_Implicit_With_Clause): New routine.
(Write_ALI): Rename array Implicit_With to Has_Implicit_With to avoid
confusion with the with clause attribute by the same name.
(Write_With_Lines): Update the emission of 'W', 'Y', and 'Z' headers.
* rtsfind.adb (Maybe_Add_With): Code cleanup.
* sem_ch8.adb (Present_System_Aux): Code cleanup.
* sem_ch10.adb (Expand_With_Clause): Mark the with clause as generated
for a parent unit.
(Implicit_With_On_Parent): Mark the with clause as generated for a
parent unit.
* sem_ch12.adb (Inherit_Context): With clauses inherited by an
instantiation are no longer marked as Implicit_With_From_Instantiation
because they are already marked as implicit.
* sem_elab.adb (Ensure_Prior_Elaboration_Static): Remove the kludge
which marks implicit with clauses as related to an instantiation.
* sinfo.adb (Implicit_With_From_Instantiation): Removed.
(Parent_With): New routine.
(Set_Implicit_With_From_Instantiation): Removed.
(Set_Parent_With): New routine.
* sinfo.ads: Update the documentation of attribute Implicit_With.
Remove attribute Implicit_With_From_Instantiation along with
occurrences in nodes. Add attribute Parent_With along with occurrences
in nodes.
(Implicit_With_From_Instantiation): Removed along with pragma Inline.
(Parent_With): New routine along with pragma Inline.
(Set_Implicit_With_From_Instantiation): Removed along with pragma Inline.
(Set_Parent_With): New routine along with pragma Inline.
From-SVN: r256490
Diffstat (limited to 'gcc/ada/lib-writ.adb')
-rw-r--r-- | gcc/ada/lib-writ.adb | 81 |
1 files changed, 69 insertions, 12 deletions
diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index 1ee329ee7f1..553bda20b5f 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -215,9 +215,9 @@ package body Lib.Writ is -- Array of flags to show which units have Elaborate_All_Desirable set type Yes_No is (Unknown, Yes, No); - Implicit_With : array (Units.First .. Last_Unit) of Yes_No; + Has_Implicit_With : array (Units.First .. Last_Unit) of Yes_No; -- Indicates if an implicit with has been given for the unit. Yes if - -- certainly present, no if certainly absent, unkonwn if not known. + -- certainly present, No if certainly absent, Unknown if not known. Sdep_Table : Unit_Ref_Table (1 .. Pos (Last_Unit - Units.First + 2)); -- Sorted table of source dependencies. One extra entry in case we @@ -235,8 +235,8 @@ package body Lib.Writ is ----------------------- procedure Collect_Withs (Cunit : Node_Id); - -- Collect with lines for entries in the context clause of the - -- given compilation unit, Cunit. + -- Collect with lines for entries in the context clause of the given + -- compilation unit, Cunit. procedure Update_Tables_From_ALI_File; -- Given an up to date ALI file (see Up_To_Date_ALI_file_Exists @@ -261,9 +261,47 @@ package body Lib.Writ is ------------------- procedure Collect_Withs (Cunit : Node_Id) is + function Is_Implicit_With_Clause (Clause : Node_Id) return Boolean; + pragma Inline (Is_Implicit_With_Clause); + -- Determine whether a with clause denoted by Clause is implicit + + ----------------------------- + -- Is_Implicit_With_Clause -- + ----------------------------- + + function Is_Implicit_With_Clause (Clause : Node_Id) return Boolean is + begin + -- With clauses created for ancestor units are marked as internal, + -- however, they emulate the semantics in Ada RM 10.1.2 (6/2), + -- where + -- + -- with A.B; + -- + -- is almost equivalent to + -- + -- with A; + -- with A.B; + -- + -- For ALI encoding purposes, they are considered to be explicit. + -- Note that the clauses cannot be marked as explicit because they + -- will be subjected to various checks related to with clauses and + -- possibly cause false positives. + + if Parent_With (Clause) then + return False; + + else + return Implicit_With (Clause); + end if; + end Is_Implicit_With_Clause; + + -- Local variables + Item : Node_Id; Unum : Unit_Number_Type; + -- Start of processing for Collect_Withs + begin Item := First (Context_Items (Cunit)); while Present (Item) loop @@ -300,12 +338,28 @@ package body Lib.Writ is Set_From_Limited_With (Cunit_Entity (Unum)); end if; - if Implicit_With (Unum) /= Yes then - if Implicit_With_From_Instantiation (Item) then - Implicit_With (Unum) := Yes; + if Is_Implicit_With_Clause (Item) then + + -- A previous explicit with clause withs the unit. Retain + -- this classification, as it reflects the source relations + -- between units. + + if Has_Implicit_With (Unum) = No then + null; + + -- Otherwise this is either the first time any clause withs + -- the unit, or the unit is already implicitly withed. + else - Implicit_With (Unum) := No; + Has_Implicit_With (Unum) := Yes; end if; + + -- Otherwise the current with clause is explicit. Such clauses + -- take precedence over existing implicit clauses because they + -- reflect the source relations between unit. + + else + Has_Implicit_With (Unum) := No; end if; end if; @@ -573,7 +627,7 @@ package body Lib.Writ is Elab_All_Flags (J) := False; Elab_Des_Flags (J) := False; Elab_All_Des_Flags (J) := False; - Implicit_With (J) := Unknown; + Has_Implicit_With (J) := Unknown; end loop; Collect_Withs (Unode); @@ -853,14 +907,17 @@ package body Lib.Writ is Uname := Units.Table (Unum).Unit_Name; Fname := Units.Table (Unum).Unit_File_Name; - if Implicit_With (Unum) = Yes then - Write_Info_Initiate ('Z'); + -- Limited with clauses must be processed first because they are + -- the most specific among the three kinds. - elsif Ekind (Cunit_Entity (Unum)) = E_Package + if Ekind (Cunit_Entity (Unum)) = E_Package and then From_Limited_With (Cunit_Entity (Unum)) then Write_Info_Initiate ('Y'); + elsif Has_Implicit_With (Unum) = Yes then + Write_Info_Initiate ('Z'); + else Write_Info_Initiate ('W'); end if; |