summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-14 08:45:05 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-14 08:45:05 +0000
commitfcdc023a8715ff3e826cf73114712889e4319607 (patch)
treed0e7a73386d172b2419d7f2ead4f393e6d2ab8d5
parent1229aa51302402029897d06bef1cface5f6c199f (diff)
downloadgcc-fcdc023a8715ff3e826cf73114712889e4319607.tar.gz
2007-08-14 Thomas Quinot <quinot@adacore.com>
Vincent Celier <celier@adacore.com> * binde.adb (Elab_All_Links): Remove unnecessary call to Generic_Separately_Compiled (if a unit satisfies this predicate, there won't be an associated Afile). (Elab_All_Links): Fail if a referenced unit cannot be found * bindgen.adb: Fix comments in bindgen regarding consistency checks done in Bcheck: the checks are made across units within a partition, not across several partitions. Fix generation of C binder file for VxWorks. * lib.adb (Generic_Separately_Compiled): Rename to Generic_May_Lack_ALI, more descriptive of the current use of the predicate, and update documentation. * lib-writ.ads, lib-writ.adb (Write_With_Lines): Minor code reorganization and documentation update for the case of predefined library generics (for which we do not reference an Afile). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127439 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/binde.adb71
-rw-r--r--gcc/ada/bindgen.adb5
-rw-r--r--gcc/ada/lib-writ.adb32
-rw-r--r--gcc/ada/lib-writ.ads10
-rw-r--r--gcc/ada/lib.adb60
5 files changed, 106 insertions, 72 deletions
diff --git a/gcc/ada/binde.adb b/gcc/ada/binde.adb
index 7479e51d346..9190db03332 100644
--- a/gcc/ada/binde.adb
+++ b/gcc/ada/binde.adb
@@ -28,12 +28,14 @@ with Binderr; use Binderr;
with Butil; use Butil;
with Debug; use Debug;
with Fname; use Fname;
-with Lib; use Lib;
with Namet; use Namet;
with Opt; use Opt;
+with Osint;
with Output; use Output;
with Targparm; use Targparm;
+with System.Case_Util; use System.Case_Util;
+
package body Binde is
-- The following data structures are used to represent the graph that is
@@ -864,18 +866,69 @@ package body Binde is
Units.Table (Before).First_With .. Units.Table (Before).Last_With
loop
-- Skip if this with is an interface to a stand-alone library.
- -- Skip also if no ALI file for this with, happens with certain
- -- specialized generic files that do not get compiled.
+ -- Skip also if no ALI file for this WITH, happens for language
+ -- defined generics while bootstrapping the compiler (see body of
+ -- Lib.Writ.Write_With_Lines).
if not Withs.Table (W).SAL_Interface
and then Withs.Table (W).Afile /= No_File
- and then Generic_Separately_Compiled (Withs.Table (W).Sfile)
then
- Elab_All_Links
- (Unit_Id_Of (Withs.Table (W).Uname),
- After,
- Reason,
- Make_Elab_Entry (Withs.Table (W).Uname, Link));
+ declare
+ Info : constant Int :=
+ Get_Name_Table_Info
+ (Withs.Table (W).Uname);
+
+ begin
+ -- If the unit is unknown, for some unknown reason, fail
+ -- graciously explaining that the unit is unknown. Without
+ -- this check, gnatbind will crash in Unit_Id_Of.
+
+ if Info = 0 or else Unit_Id (Info) = No_Unit_Id then
+ declare
+ Withed : String :=
+ Get_Name_String (Withs.Table (W).Uname);
+ Last_Withed : Natural := Withed'Last;
+ Withing : String :=
+ Get_Name_String
+ (Units.Table (Before).Uname);
+ Last_Withing : Natural := Withing'Last;
+ Spec_Body : String := " (Spec)";
+
+ begin
+ To_Mixed (Withed);
+ To_Mixed (Withing);
+
+ if Last_Withed > 2 and then
+ Withed (Last_Withed - 1) = '%'
+ then
+ Last_Withed := Last_Withed - 2;
+ end if;
+
+ if Last_Withing > 2 and then
+ Withing (Last_Withing - 1) = '%'
+ then
+ Last_Withing := Last_Withing - 2;
+ end if;
+
+ if Units.Table (Before).Utype = Is_Body or else
+ Units.Table (Before).Utype = Is_Body_Only
+ then
+ Spec_Body := " (Body)";
+ end if;
+
+ Osint.Fail
+ ("could not find unit ",
+ Withed (Withed'First .. Last_Withed) & " needed by " &
+ Withing (Withing'First .. Last_Withing) & Spec_Body);
+ end;
+ end if;
+
+ Elab_All_Links
+ (Unit_Id_Of (Withs.Table (W).Uname),
+ After,
+ Reason,
+ Make_Elab_Entry (Withs.Table (W).Uname, Link));
+ end;
end if;
end loop;
diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
index c5ae10f2768..e515992a941 100644
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -77,7 +77,7 @@ package body Bindgen is
-- This table assembles the interface state pragma information from
-- all the units in the partition. Note that Bcheck has already checked
- -- that the information is consistent across partitions. The entries
+ -- that the information is consistent across units. The entries
-- in this table are n/u/r/s for not set/user/runtime/system.
package IS_Pragma_Settings is new Table.Table (
@@ -90,7 +90,7 @@ package body Bindgen is
-- This table assembles the Priority_Specific_Dispatching pragma
-- information from all the units in the partition. Note that Bcheck has
- -- already checked that the information is consistent across partitions.
+ -- already checked that the information is consistent across units.
-- The entries in this table are the upper case first character of the
-- policy name, e.g. 'F' for FIFO_Within_Priorities.
@@ -1590,7 +1590,6 @@ package body Bindgen is
-- if no command line arguments on target, set dummy values
else
- WBI (" int result;");
WBI (" gnat_argc = 0;");
WBI (" gnat_argv = 0;");
WBI (" gnat_envp = 0;");
diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb
index d62b70d95af..661fc321260 100644
--- a/gcc/ada/lib-writ.adb
+++ b/gcc/ada/lib-writ.adb
@@ -376,11 +376,8 @@ package body Lib.Writ is
Write_Info_Str (" DE");
end if;
- -- We set the Elaborate_Body indication if either an explicit pragma
- -- was present, or if this is an instantiation. RM 12.3(20) requires
- -- that the body be immediately elaborated after the spec. We would
- -- normally do that anyway, but the EB we generate here ensures that
- -- this gets done even when we use the -p gnatbind switch.
+ -- Set the Elaborate_Body indication if either an explicit pragma
+ -- was present, or if this is an instantiation.
if Has_Pragma_Elaborate_Body (Uent)
or else (Ukind = N_Package_Declaration
@@ -391,8 +388,8 @@ package body Lib.Writ is
end if;
-- Now see if we should tell the binder that an elaboration entity
- -- is present, which must be reset to true during elaboration. We
- -- generate the indication if the following condition is met:
+ -- is present, which must be set to true during elaboration.
+ -- We generate the indication if the following condition is met:
-- If this is a spec ...
@@ -630,7 +627,6 @@ package body Lib.Writ is
Num_Withs : Int := 0;
Unum : Unit_Number_Type;
Cunit : Node_Id;
- Cunite : Entity_Id;
Uname : Unit_Name_Type;
Fname : File_Name_Type;
Pname : constant Unit_Name_Type :=
@@ -696,7 +692,6 @@ package body Lib.Writ is
for J in 1 .. Num_Withs loop
Unum := With_Table (J);
Cunit := Units.Table (Unum).Cunit;
- Cunite := Units.Table (Unum).Cunit_Entity;
Uname := Units.Table (Unum).Unit_Name;
Fname := Units.Table (Unum).Unit_File_Name;
@@ -706,12 +701,19 @@ package body Lib.Writ is
-- Now we need to figure out the names of the files that contain
-- the with'ed unit. These will usually be the files for the body,
- -- except in the case of a package that has no body.
-
- if (Nkind (Unit (Cunit)) not in N_Generic_Declaration
- and then
- Nkind (Unit (Cunit)) not in N_Generic_Renaming_Declaration)
- or else Generic_Separately_Compiled (Cunite)
+ -- except in the case of a package that has no body. Note that we
+ -- have a specific exemption here for predefined library generics
+ -- (see comments for Generic_May_Lack_ALI). We do not generate
+ -- dependency upon the ALI file for such units. Older compilers
+ -- used to not support generating code (and ALI) for generics, and
+ -- we want to avoid having different processing (namely, different
+ -- lists of files to be compiled) for different stages of the
+ -- bootstrap.
+
+ if not ((Nkind (Unit (Cunit)) in N_Generic_Declaration
+ or else
+ Nkind (Unit (Cunit)) in N_Generic_Renaming_Declaration)
+ and then Generic_May_Lack_ALI (Fname))
then
Write_Info_Tab (25);
diff --git a/gcc/ada/lib-writ.ads b/gcc/ada/lib-writ.ads
index 0d4a160f604..50eb9eae3bf 100644
--- a/gcc/ada/lib-writ.ads
+++ b/gcc/ada/lib-writ.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2007, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -435,7 +435,13 @@ package Lib.Writ is
-- dynamic elaboration model, as set by either the -gnatE
-- switch or pragma Elaboration_Checks (Dynamic).
--
- -- EB Unit has pragma Elaborate_Body
+ -- EB Unit has pragma Elaborate_Body, or is a generic instance
+ -- that has a body. Set for instances because RM 12.3(20)
+ -- requires that the body be immediately elaborated after the
+ -- spec (we would normally do that anyway, because elaborate
+ -- spec and body together whenever possible, and for an instance
+ -- it is always possible; however setting EB ensures that this
+ -- is done even when using the -p gnatbind switch).
--
-- EE Elaboration entity is present which must be set true when
-- the unit is elaborated. The name of the elaboration entity
diff --git a/gcc/ada/lib.adb b/gcc/ada/lib.adb
index c4afe04d0e4..7c5db5df88b 100644
--- a/gcc/ada/lib.adb
+++ b/gcc/ada/lib.adb
@@ -447,49 +447,23 @@ package body Lib is
return False;
end Entity_Is_In_Main_Unit;
- ---------------------------------
- -- Generic_Separately_Compiled --
- ---------------------------------
-
- function Generic_Separately_Compiled (E : Entity_Id) return Boolean is
- begin
- -- We do not generate object files for internal generics, because
- -- the only thing they would contain is the elaboration boolean, and
- -- we are careful to elaborate all predefined units first anyway, so
- -- this boolean is not needed.
-
- if Is_Internal_File_Name
- (Fname => Unit_File_Name (Get_Source_Unit (E)),
- Renamings_Included => True)
- then
- return False;
-
- -- All other generic units do generate object files
-
- else
- return True;
- end if;
- end Generic_Separately_Compiled;
-
- function Generic_Separately_Compiled
- (Sfile : File_Name_Type) return Boolean
- is
- begin
- -- Exactly the same as previous function, but works directly on a file
- -- name.
-
- if Is_Internal_File_Name
- (Fname => Sfile,
- Renamings_Included => True)
- then
- return False;
-
- -- All other generic units do generate object files
-
- else
- return True;
- end if;
- end Generic_Separately_Compiled;
+ --------------------------
+ -- Generic_May_Lack_ALI --
+ --------------------------
+
+ function Generic_May_Lack_ALI (Sfile : File_Name_Type) return Boolean is
+ begin
+ -- We allow internal generic units to be used without having a
+ -- corresponding ALI files to help bootstrapping with older compilers
+ -- that did not support generating ALIs for such generics. It is safe
+ -- to do so because the only thing the generated code would contain
+ -- is the elaboration boolean, and we are careful to elaborate all
+ -- predefined units first anyway.
+
+ return Is_Internal_File_Name
+ (Fname => Sfile,
+ Renamings_Included => True);
+ end Generic_May_Lack_ALI;
-----------------------------
-- Get_Code_Or_Source_Unit --