OSDN Git Service

Fix aliasing bug that also caused memory usage problems.
[pf3gnuchains/gcc-fork.git] / gcc / ada / lib.adb
index d1e8781..e64db77 100644 (file)
@@ -50,6 +50,9 @@ with Uname;   use Uname;
 
 package body Lib is
 
+   Switch_Storing_Enabled : Boolean := True;
+   --  Set to False by Disable_Switch_Storing
+
    -----------------------
    -- Local Subprograms --
    -----------------------
@@ -403,6 +406,11 @@ package body Lib is
       return Compilation_Switches.Last;
    end Compilation_Switches_Last;
 
+   procedure Disable_Switch_Storing is
+   begin
+      Switch_Storing_Enabled := False;
+   end Disable_Switch_Storing;
+
    ------------------------------
    -- Earlier_In_Extended_Unit --
    ------------------------------
@@ -640,7 +648,7 @@ package body Lib is
 
       else
          return
-           In_Same_Extended_Unit (Sloc (N), Sloc (Cunit (Main_Unit)));
+           In_Same_Extended_Unit (N, Cunit (Main_Unit));
       end if;
    end In_Extended_Main_Code_Unit;
 
@@ -765,6 +773,13 @@ package body Lib is
    -- In_Same_Extended_Unit --
    ---------------------------
 
+   function In_Same_Extended_Unit
+     (N1, N2 : Node_Or_Entity_Id) return Boolean
+   is
+   begin
+      return Check_Same_Extended_Unit (Sloc (N1), Sloc (N2)) /= No;
+   end In_Same_Extended_Unit;
+
    function In_Same_Extended_Unit (S1, S2 : Source_Ptr) return Boolean is
    begin
       return Check_Same_Extended_Unit (S1, S2) /= No;
@@ -914,18 +929,20 @@ package body Lib is
 
    procedure Store_Compilation_Switch (Switch : String) is
    begin
-      Compilation_Switches.Increment_Last;
-      Compilation_Switches.Table (Compilation_Switches.Last) :=
-        new String'(Switch);
+      if Switch_Storing_Enabled then
+         Compilation_Switches.Increment_Last;
+         Compilation_Switches.Table (Compilation_Switches.Last) :=
+           new String'(Switch);
 
-      --  Fix up --RTS flag which has been transformed by the gcc driver
-      --  into -fRTS
+         --  Fix up --RTS flag which has been transformed by the gcc driver
+         --  into -fRTS
 
-      if Switch'Last >= Switch'First + 4
-        and then Switch (Switch'First .. Switch'First + 4) = "-fRTS"
-      then
-         Compilation_Switches.Table
-           (Compilation_Switches.Last) (Switch'First + 1) := '-';
+         if Switch'Last >= Switch'First + 4
+           and then Switch (Switch'First .. Switch'First + 4) = "-fRTS"
+         then
+            Compilation_Switches.Table
+              (Compilation_Switches.Last) (Switch'First + 1) := '-';
+         end if;
       end if;
    end Store_Compilation_Switch;