OSDN Git Service

* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Procedure>: Set default
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat1drv.adb
index b787556..7982486 100644 (file)
@@ -45,10 +45,12 @@ with Nlists;
 with Opt;      use Opt;
 with Osint;    use Osint;
 with Output;   use Output;
+with Par_SCO;
 with Prepcomp;
 with Repinfo;  use Repinfo;
 with Restrict;
 with Rtsfind;
+with SCOs;
 with Sem;
 with Sem_Ch8;
 with Sem_Ch12;
@@ -110,9 +112,12 @@ procedure Gnat1drv is
 
    procedure Adjust_Global_Switches is
    begin
-      --  Debug flag -gnatd.I is a synonym of Generate_SCIL
+      --  Debug flag -gnatd.I is a synonym for Generate_SCIL and requires code
+      --  generation.
 
-      if Debug_Flag_Dot_II then
+      if Debug_Flag_Dot_II
+        and then Operating_Mode = Generate_Code
+      then
          Generate_SCIL := True;
       end if;
 
@@ -148,33 +153,56 @@ procedure Gnat1drv is
 
       if CodePeer_Mode then
 
-         --  Turn off inlining, confuses codepeer output and gains nothing
+         --  Turn off inlining, confuses CodePeer output and gains nothing
 
          Front_End_Inlining := False;
          Inline_Active      := False;
 
-         --  Turn off ASIS mode: incompatible with front-end expansion.
+         --  Turn off ASIS mode: incompatible with front-end expansion
 
          ASIS_Mode := False;
 
-         --  Turn off dynamic elaboration checks: generates inconsitencies in
+         --  Disable front-end optimizations, to keep the tree as close to the
+         --  source code as possible, and also to avoid inconsistencies between
+         --  trees when using different optimization switches.
+
+         Optimization_Level := 0;
+
+         --  Disable specific expansions for Restrictions pragmas to avoid
+         --  tree inconsistencies between compilations with different pragmas
+         --  that will cause different SCIL files to be generated for the
+         --  same Ada spec.
+
+         Treat_Restrictions_As_Warnings := True;
+
+         --  Suppress overflow, division by zero and access checks since they
+         --  are handled implicitly by CodePeer.
+
+         --  Turn off dynamic elaboration checks: generates inconsistencies in
          --  trees between specs compiled as part of a main unit or as part of
          --  a with-clause.
 
-         Dynamic_Elaboration_Checks := False;
+         --  Turn off alignment checks: these cannot be proved statically by
+         --  CodePeer and generate false positives.
 
-         --  Suppress overflow checks since this is handled implicitely by
-         --  codepeer. Enable all other language checks.
+         --  Enable all other language checks
 
-         Suppress_Options       := (Overflow_Check => True, others => False);
+         Suppress_Options :=
+           (Access_Check      => True,
+            Alignment_Check   => True,
+            Division_Check    => True,
+            Elaboration_Check => True,
+            Overflow_Check    => True,
+            others            => False);
          Enable_Overflow_Checks := False;
+         Dynamic_Elaboration_Checks := False;
 
          --  Kill debug of generated code, since it messes up sloc values
 
          Debug_Generated_Code := False;
 
          --  Turn cross-referencing on in case it was disabled (by e.g. -gnatD)
-         --  Do we really need to spend time generating xref in codepeer
+         --  Do we really need to spend time generating xref in CodePeer
          --  mode??? Consider setting Xref_Active to False.
 
          Xref_Active := True;
@@ -183,36 +211,35 @@ procedure Gnat1drv is
 
          Polling_Required := False;
 
-         --  Set operating mode to check semantics with full front-end
-         --  expansion, but no back-end code generation.
+         --  Set operating mode to Generate_Code to benefit from full
+         --  front-end expansion (e.g. generics).
 
-         Operating_Mode := Check_Semantics;
-         Debug_Flag_X   := True;
+         Operating_Mode := Generate_Code;
 
          --  We need SCIL generation of course
 
          Generate_SCIL := True;
 
-         --  Enable assertions and debug pragmas, since they give codepeer
+         --  Enable assertions and debug pragmas, since they give CodePeer
          --  valuable extra information.
 
          Assertions_Enabled     := True;
          Debug_Pragmas_Enabled  := True;
 
          --  Suppress compiler warnings, since what we are interested in here
-         --  is what codepeer can find out. Also disable all simple value
+         --  is what CodePeer can find out. Also disable all simple value
          --  propagation. This is an optimization which is valuable for code
          --  optimization, and also for generation of compiler warnings, but
-         --  these are being turned off anyway, and codepeer understands
+         --  these are being turned off anyway, and CodePeer understands
          --  things more clearly if references are not optimized in this way.
 
          Warning_Mode  := Suppress;
          Debug_Flag_MM := True;
 
          --  Set normal RM validity checking, and checking of IN OUT parameters
-         --  (this might give codepeer more useful checks to analyze, to be
+         --  (this might give CodePeer more useful checks to analyze, to be
          --  confirmed???). All other validity checking is turned off, since
-         --  this can generate very complex trees that only confuse codepeer
+         --  this can generate very complex trees that only confuse CodePeer
          --  and do not bring enough useful info.
 
          Reset_Validity_Check_Options;
@@ -221,7 +248,7 @@ procedure Gnat1drv is
          Validity_Check_In_Params     := True;
 
          --  Turn off style check options since we are not interested in any
-         --  front-end warnings when we are getting code peer output.
+         --  front-end warnings when we are getting CodePeer output.
 
          Reset_Style_Check_Options;
       end if;
@@ -449,25 +476,6 @@ procedure Gnat1drv is
       end if;
    end Check_Bad_Body;
 
-   --------------------
-   -- Check_Rep_Info --
-   --------------------
-
-   procedure Check_Rep_Info is
-   begin
-      if List_Representation_Info /= 0
-        or else List_Representation_Info_Mechanisms
-      then
-         Set_Standard_Error;
-         Write_Eol;
-         Write_Str
-           ("cannot generate representation information, no code generated");
-         Write_Eol;
-         Write_Eol;
-         Set_Standard_Output;
-      end if;
-   end Check_Rep_Info;
-
    -------------------------
    -- Check_Library_Items --
    -------------------------
@@ -497,6 +505,25 @@ procedure Gnat1drv is
       Walk;
    end Check_Library_Items;
 
+   --------------------
+   -- Check_Rep_Info --
+   --------------------
+
+   procedure Check_Rep_Info is
+   begin
+      if List_Representation_Info /= 0
+        or else List_Representation_Info_Mechanisms
+      then
+         Set_Standard_Error;
+         Write_Eol;
+         Write_Str
+           ("cannot generate representation information, no code generated");
+         Write_Eol;
+         Write_Eol;
+         Set_Standard_Output;
+      end if;
+   end Check_Rep_Info;
+
 --  Start of processing for Gnat1drv
 
 begin
@@ -506,6 +533,9 @@ begin
    --  nested blocks, so that the outer one handles unrecoverable error.
 
    begin
+      --  Initialize all packages. For the most part, these initialization
+      --  calls can be made in any order. Exceptions are as follows:
+
       --  Lib.Initialize need to be called before Scan_Compiler_Arguments,
       --  because it initializes a table filled by Scan_Compiler_Arguments.
 
@@ -524,9 +554,11 @@ begin
       Urealp.Initialize;
       Errout.Initialize;
       Namet.Initialize;
+      SCOs.Initialize;
       Snames.Initialize;
       Stringt.Initialize;
       Inline.Initialize;
+      Par_SCO.Initialize;
       Sem_Ch8.Initialize;
       Sem_Ch12.Initialize;
       Sem_Ch13.Initialize;
@@ -745,6 +777,11 @@ begin
       elsif Main_Kind in N_Generic_Renaming_Declaration then
          Back_End_Mode := Generate_Object;
 
+      --  It's not an error to generate SCIL for e.g. a spec which has a body
+
+      elsif CodePeer_Mode then
+         Back_End_Mode := Generate_Object;
+
       --  In all other cases (specs which have bodies, generics, and bodies
       --  where subunits are missing), we cannot generate code and we generate
       --  a warning message. Note that generic instantiations are gone at this