]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Output.w always writes to stderr
authorBob Duff <duff@adacore.com>
Wed, 23 Mar 2022 14:27:44 +0000 (10:27 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 17 May 2022 08:25:46 +0000 (08:25 +0000)
There are several debugging procedures called Output.w, and some
output-redirection features. This patch modifies Output.w so their
output is not redirected; it always goes to standard error. Otherwise,
debugging output can get mixed in with some "real" output (perhaps to a
file), which causes confusion and in some cases failure to build.

gcc/ada/

* output.adb (Pop_Output, Set_Output): Unconditionally flush
output when switching from one output destination to another.
Otherwise buffering can cause garbled output.
(w): Push/pop the current settings, and temporarily
Set_Standard_Error during these procedures.

gcc/ada/output.adb

index bdb2a44bf6ba43354f8c08e1851482512377987a..33d027ded8e38ad6c23a29af56266454fd4b6b70 100644 (file)
@@ -235,6 +235,7 @@ package body Output is
 
    procedure Pop_Output is
    begin
+      Flush_Buffer;
       pragma Assert (FD_Stack_Idx >= FD_Array'First);
       Current_FD := FD_Stack (FD_Stack_Idx);
       FD_Stack_Idx := FD_Stack_Idx - 1;
@@ -292,10 +293,7 @@ package body Output is
 
    procedure Set_Output (FD : File_Descriptor) is
    begin
-      if Special_Output_Proc = null then
-         Flush_Buffer;
-      end if;
-
+      Flush_Buffer;
       Current_FD := FD;
    end Set_Output;
 
@@ -323,59 +321,99 @@ package body Output is
 
    procedure w (C : Character) is
    begin
+      Push_Output;
+      Set_Standard_Error;
+
       Write_Char (''');
       Write_Char (C);
       Write_Char (''');
       Write_Eol;
+
+      Pop_Output;
    end w;
 
    procedure w (S : String) is
    begin
+      Push_Output;
+      Set_Standard_Error;
+
       Write_Str (S);
       Write_Eol;
+
+      Pop_Output;
    end w;
 
    procedure w (V : Int) is
    begin
+      Push_Output;
+      Set_Standard_Error;
+
       Write_Int (V);
       Write_Eol;
+
+      Pop_Output;
    end w;
 
    procedure w (B : Boolean) is
    begin
+      Push_Output;
+      Set_Standard_Error;
+
       if B then
          w ("True");
       else
          w ("False");
       end if;
+
+      Pop_Output;
    end w;
 
    procedure w (L : String; C : Character) is
    begin
+      Push_Output;
+      Set_Standard_Error;
+
       Write_Str (L);
       Write_Char (' ');
       w (C);
+
+      Pop_Output;
    end w;
 
    procedure w (L : String; S : String) is
    begin
+      Push_Output;
+      Set_Standard_Error;
+
       Write_Str (L);
       Write_Char (' ');
       w (S);
+
+      Pop_Output;
    end w;
 
    procedure w (L : String; V : Int) is
    begin
+      Push_Output;
+      Set_Standard_Error;
+
       Write_Str (L);
       Write_Char (' ');
       w (V);
+
+      Pop_Output;
    end w;
 
    procedure w (L : String; B : Boolean) is
    begin
+      Push_Output;
+      Set_Standard_Error;
+
       Write_Str (L);
       Write_Char (' ');
       w (B);
+
+      Pop_Output;
    end w;
 
    ----------------