public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2106] [Ada] Simplify handling of Generate_Code flag for compilation units
@ 2021-07-07 16:24 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-07-07 16:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:05435609367c0ae1398ac1b4becfae06d217552c
commit r12-2106-g05435609367c0ae1398ac1b4becfae06d217552c
Author: Piotr Trojanek <trojanek@adacore.com>
Date: Tue May 18 14:54:24 2021 +0200
[Ada] Simplify handling of Generate_Code flag for compilation units
gcc/ada/
* gnat1drv.adb (Gnat1drv): Remove flagging of main unit and its
corresponding spec as requiring code generation; now the flags
are set much earlier.
* lib-load.adb (Load_Main_Source): Set Generate_Code flag on the
main unit source.
(Make_Instance_Unit): Copy Generate_Code flag from the main unit
to instance units.
* lib-writ.adb (Write_ALI): Remove redundant condition;
Generate_Code flag is always set for the main unit.
* par-load.adb (Load): Set Generate_Code flag on the main unit's
corresponding spec, if any.
Diff:
---
gcc/ada/gnat1drv.adb | 23 -----------------------
gcc/ada/lib-load.adb | 11 +++++------
gcc/ada/lib-writ.adb | 2 +-
gcc/ada/par-load.adb | 6 ++++++
4 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb
index 22c93113709..6f65d7480f2 100644
--- a/gcc/ada/gnat1drv.adb
+++ b/gcc/ada/gnat1drv.adb
@@ -1287,29 +1287,6 @@ begin
Exit_Program (E_Errors);
end if;
- -- Set Generate_Code on main unit and its spec. We do this even if are
- -- not generating code, since Lib-Writ uses this to determine which
- -- units get written in the ali file.
-
- Set_Generate_Code (Main_Unit);
-
- -- If we have a corresponding spec, and it comes from source or it is
- -- not a generated spec for a child subprogram body, then we need object
- -- code for the spec unit as well.
-
- if Nkind (Unit (Main_Unit_Node)) in N_Unit_Body
- and then not Acts_As_Spec (Main_Unit_Node)
- then
- if Nkind (Unit (Main_Unit_Node)) = N_Subprogram_Body
- and then not Comes_From_Source (Library_Unit (Main_Unit_Node))
- then
- null;
- else
- Set_Generate_Code
- (Get_Cunit_Unit_Number (Library_Unit (Main_Unit_Node)));
- end if;
- end if;
-
-- Case of no code required to be generated, exit indicating no error
if Original_Operating_Mode = Check_Syntax then
diff --git a/gcc/ada/lib-load.adb b/gcc/ada/lib-load.adb
index 75b52e2240a..19afe268ea7 100644
--- a/gcc/ada/lib-load.adb
+++ b/gcc/ada/lib-load.adb
@@ -364,7 +364,7 @@ package body Lib.Load is
Error_Location => No_Location,
Expected_Unit => No_Unit_Name,
Fatal_Error => None,
- Generate_Code => False,
+ Generate_Code => True,
Has_RACW => False,
Filler => False,
Ident_String => Empty,
@@ -964,13 +964,12 @@ package body Lib.Load is
Units.Increment_Last;
if In_Main then
- Units.Table (Units.Last) := Units.Table (Main_Unit);
- Units.Table (Units.Last).Cunit := Library_Unit (N);
- Units.Table (Units.Last).Generate_Code := True;
+ Units.Table (Units.Last) := Units.Table (Main_Unit);
+ Units.Table (Units.Last).Cunit := Library_Unit (N);
Init_Unit_Name (Units.Last, Unit_Name (Main_Unit));
- Units.Table (Main_Unit).Cunit := N;
- Units.Table (Main_Unit).Version := Source_Checksum (Sind);
+ Units.Table (Main_Unit).Cunit := N;
+ Units.Table (Main_Unit).Version := Source_Checksum (Sind);
Init_Unit_Name (Main_Unit,
Get_Body_Name
(Unit_Name (Get_Cunit_Unit_Number (Library_Unit (N)))));
diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb
index 3564f0f84a9..416052c943e 100644
--- a/gcc/ada/lib-writ.adb
+++ b/gcc/ada/lib-writ.adb
@@ -1253,7 +1253,7 @@ package body Lib.Writ is
-- for which we have generated code
for Unit in Units.First .. Last_Unit loop
- if Units.Table (Unit).Generate_Code or else Unit = Main_Unit then
+ if Units.Table (Unit).Generate_Code then
if not Has_No_Elaboration_Code (Cunit (Unit)) then
Main_Restrictions.Violated (No_Elaboration_Code) := True;
exit;
diff --git a/gcc/ada/par-load.adb b/gcc/ada/par-load.adb
index 39c445ea992..0773f36946f 100644
--- a/gcc/ada/par-load.adb
+++ b/gcc/ada/par-load.adb
@@ -265,6 +265,12 @@ begin
-- and this is also where we generate the SCO's for this spec.
if Cur_Unum = Main_Unit then
+
+ -- We generate code for the main unit body, so we need to generate
+ -- code for its spec too.
+
+ Set_Generate_Code (Unum, True);
+
Main_Unit_Entity := Cunit_Entity (Unum);
if Generate_SCO then
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-07 16:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 16:24 [gcc r12-2106] [Ada] Simplify handling of Generate_Code flag for compilation units Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).