Reuse the same implementation in Errout and Errutil.
gcc/ada/ChangeLog:
* errout.adb: Remove implmentation of Write_Error_Summary.
* erroutc.adb: Add implemenetation of Write_Error_Summary.
* erroutc.ads: Add spec of Write_Error_Summary.
* errutil.adb: Remove implementation for writing the error summary.
-- Emit all error messages in the table use the pretty printed format if
-- -gnatdF is used otherwise use the brief format.
- procedure Write_Error_Summary;
- -- Write error summary
-
procedure Write_Header (Sfile : Source_File_Index);
-- Write header line (compiling or checking given file)
Set_Standard_Output;
end Emit_Error_Msgs;
- -------------------------
- -- Write_Error_Summary --
- -------------------------
-
- procedure Write_Error_Summary is
- begin
- -- Extra blank line if error messages or source listing were output
-
- if Total_Errors_Detected + Warnings_Detected > 0 or else Full_List
- then
- Write_Eol;
- end if;
-
- -- Message giving number of lines read and number of errors detected.
- -- This normally goes to Standard_Output. The exception is when brief
- -- mode is not set, verbose mode (or full list mode) is set, and
- -- there are errors. In this case we send the message to standard
- -- error to make sure that *something* appears on standard error
- -- in an error situation.
-
- if Total_Errors_Detected + Warnings_Detected /= 0
- and then not Brief_Output
- and then (Verbose_Mode or Full_List)
- then
- Set_Standard_Error;
- end if;
-
- -- Message giving total number of lines. Don't give this message if
- -- the Main_Source line is unknown (this happens in error situations,
- -- e.g. when integrated preprocessing fails).
-
- if Main_Source_File > No_Source_File then
- Write_Str (" ");
- Write_Int (Num_Source_Lines (Main_Source_File));
-
- if Num_Source_Lines (Main_Source_File) = 1 then
- Write_Str (" line: ");
- else
- Write_Str (" lines: ");
- end if;
- end if;
-
- if Total_Errors_Detected = 0 then
- Write_Str ("No errors");
-
- elsif Total_Errors_Detected = 1 then
- Write_Str ("1 error");
-
- else
- Write_Int (Total_Errors_Detected);
- Write_Str (" errors");
- end if;
-
- -- We now need to output warnings. When using -gnatwe, all warnings
- -- should be treated as errors, except for warnings originating from
- -- the use of the Compile_Time_Warning pragma. Another situation
- -- where a warning might be treated as an error is when the source
- -- code contains a Warning_As_Error pragma.
- -- When warnings are treated as errors, we still log them as
- -- warnings, but we add a message denoting how many of these warnings
- -- are also errors.
-
- declare
- Warnings_Count : constant Int := Warnings_Detected;
-
- Compile_Time_Warnings : Int;
- -- Number of warnings that come from a Compile_Time_Warning
- -- pragma.
-
- Non_Compile_Time_Warnings : Int;
- -- Number of warnings that do not come from a Compile_Time_Warning
- -- pragmas.
-
- begin
- if Warnings_Count > 0 then
- Write_Str (", ");
- Write_Int (Warnings_Count);
- Write_Str (" warning");
-
- if Warnings_Count > 1 then
- Write_Char ('s');
- end if;
-
- Compile_Time_Warnings := Count_Compile_Time_Pragma_Warnings;
- Non_Compile_Time_Warnings :=
- Warnings_Count - Compile_Time_Warnings;
-
- if Warning_Mode = Treat_As_Error
- and then Non_Compile_Time_Warnings > 0
- then
- Write_Str (" (");
-
- if Compile_Time_Warnings > 0 then
- Write_Int (Non_Compile_Time_Warnings);
- Write_Str (" ");
- end if;
-
- Write_Str ("treated as error");
-
- if Non_Compile_Time_Warnings > 1 then
- Write_Char ('s');
- end if;
-
- Write_Char (')');
-
- elsif Warnings_Treated_As_Errors > 0 then
- Write_Str (" (");
-
- if Warnings_Treated_As_Errors /= Warnings_Count then
- Write_Int (Warnings_Treated_As_Errors);
- Write_Str (" ");
- end if;
-
- Write_Str ("treated as error");
-
- if Warnings_Treated_As_Errors > 1 then
- Write_Str ("s");
- end if;
-
- Write_Str (")");
- end if;
- end if;
- end;
-
- if Info_Messages /= 0 then
- Write_Str (", ");
- Write_Int (Info_Messages);
- Write_Str (" info message");
-
- if Info_Messages > 1 then
- Write_Char ('s');
- end if;
- end if;
-
- Write_Eol;
- Set_Standard_Output;
- end Write_Error_Summary;
-
------------------
-- Write_Header --
------------------
end if;
end Warnings_Suppressed;
+ -------------------------
+ -- Write_Error_Summary --
+ -------------------------
+
+ procedure Write_Error_Summary is
+ begin
+ -- Extra blank line if error messages or source listing were output
+
+ if Total_Errors_Detected + Warnings_Detected > 0 or else Full_List
+ then
+ Write_Eol;
+ end if;
+
+ -- Message giving number of lines read and number of errors detected.
+ -- This normally goes to Standard_Output. The exception is when brief
+ -- mode is not set, verbose mode (or full list mode) is set, and
+ -- there are errors. In this case we send the message to standard
+ -- error to make sure that *something* appears on standard error
+ -- in an error situation.
+
+ if Total_Errors_Detected + Warnings_Detected /= 0
+ and then not Brief_Output
+ and then (Verbose_Mode or Full_List)
+ then
+ Set_Standard_Error;
+ end if;
+
+ -- Message giving total number of lines. Don't give this message if
+ -- the Main_Source line is unknown (this happens in error situations,
+ -- e.g. when integrated preprocessing fails).
+
+ if Main_Source_File > No_Source_File then
+ Write_Str (" ");
+ Write_Int (Num_Source_Lines (Main_Source_File));
+
+ if Num_Source_Lines (Main_Source_File) = 1 then
+ Write_Str (" line: ");
+ else
+ Write_Str (" lines: ");
+ end if;
+ end if;
+
+ if Total_Errors_Detected = 0 then
+ Write_Str ("No errors");
+
+ elsif Total_Errors_Detected = 1 then
+ Write_Str ("1 error");
+
+ else
+ Write_Int (Total_Errors_Detected);
+ Write_Str (" errors");
+ end if;
+
+ -- We now need to output warnings. When using -gnatwe, all warnings
+ -- should be treated as errors, except for warnings originating from
+ -- the use of the Compile_Time_Warning pragma. Another situation
+ -- where a warning might be treated as an error is when the source
+ -- code contains a Warning_As_Error pragma.
+ -- When warnings are treated as errors, we still log them as
+ -- warnings, but we add a message denoting how many of these warnings
+ -- are also errors.
+
+ declare
+ Warnings_Count : constant Int := Warnings_Detected;
+
+ Compile_Time_Warnings : Int;
+ -- Number of warnings that come from a Compile_Time_Warning
+ -- pragma.
+
+ Non_Compile_Time_Warnings : Int;
+ -- Number of warnings that do not come from a Compile_Time_Warning
+ -- pragmas.
+
+ begin
+ if Warnings_Count > 0 then
+ Write_Str (", ");
+ Write_Int (Warnings_Count);
+ Write_Str (" warning");
+
+ if Warnings_Count > 1 then
+ Write_Char ('s');
+ end if;
+
+ Compile_Time_Warnings := Count_Compile_Time_Pragma_Warnings;
+ Non_Compile_Time_Warnings :=
+ Warnings_Count - Compile_Time_Warnings;
+
+ if Warning_Mode = Treat_As_Error
+ and then Non_Compile_Time_Warnings > 0
+ then
+ Write_Str (" (");
+
+ if Compile_Time_Warnings > 0 then
+ Write_Int (Non_Compile_Time_Warnings);
+ Write_Str (" ");
+ end if;
+
+ Write_Str ("treated as error");
+
+ if Non_Compile_Time_Warnings > 1 then
+ Write_Char ('s');
+ end if;
+
+ Write_Char (')');
+
+ elsif Warnings_Treated_As_Errors > 0 then
+ Write_Str (" (");
+
+ if Warnings_Treated_As_Errors /= Warnings_Count then
+ Write_Int (Warnings_Treated_As_Errors);
+ Write_Str (" ");
+ end if;
+
+ Write_Str ("treated as error");
+
+ if Warnings_Treated_As_Errors > 1 then
+ Write_Str ("s");
+ end if;
+
+ Write_Str (")");
+ end if;
+ end if;
+ end;
+
+ if Info_Messages /= 0 then
+ Write_Str (", ");
+ Write_Int (Info_Messages);
+ Write_Str (" info message");
+
+ if Info_Messages > 1 then
+ Write_Char ('s');
+ end if;
+ end if;
+
+ Write_Eol;
+ Set_Standard_Output;
+ end Write_Error_Summary;
+
end Erroutc;
-- given by Warning_As_Error pragmas, as stored in the Warnings_As_Errors
-- table.
+ procedure Write_Error_Summary;
+ -- Write error summary
+
end Erroutc;
-- Output error summary if verbose or full list mode
if Verbose_Mode or else Full_List then
-
- -- Extra blank line if error messages or source listing were output
-
- if Total_Errors_Detected + Warnings_Detected > 0
- or else Full_List
- then
- Write_Eol;
- end if;
-
- -- Message giving number of lines read and number of errors detected.
- -- This normally goes to Standard_Output. The exception is when brief
- -- mode is not set, verbose mode (or full list mode) is set, and
- -- there are errors. In this case we send the message to standard
- -- error to make sure that *something* appears on standard error in
- -- an error situation.
-
- -- Historical note: Formerly, only the "# errors" suffix was sent
- -- to stderr, whereas "# lines:" appeared on stdout. This caused
- -- some problems on now-obsolete ports, but there seems to be no
- -- reason to revert this page since it would be incompatible.
-
- if Total_Errors_Detected + Warnings_Detected /= 0
- and then not Brief_Output
- and then (Verbose_Mode or Full_List)
- then
- Set_Standard_Error;
- end if;
-
- -- Message giving total number of lines
-
- Write_Str (" ");
- Write_Int (Num_Source_Lines (Main_Source_File));
-
- if Num_Source_Lines (Main_Source_File) = 1 then
- Write_Str (" line: ");
- else
- Write_Str (" lines: ");
- end if;
-
- if Total_Errors_Detected = 0 then
- Write_Str ("No errors");
-
- elsif Total_Errors_Detected = 1 then
- Write_Str ("1 error");
-
- else
- Write_Int (Total_Errors_Detected);
- Write_Str (" errors");
- end if;
-
- if Warnings_Detected /= 0 then
- Write_Str (", ");
- Write_Int (Warnings_Detected);
- Write_Str (" warning");
-
- if Warnings_Detected /= 1 then
- Write_Char ('s');
- end if;
-
- if Warning_Mode = Treat_As_Error then
- Write_Str (" (treated as error");
-
- if Warnings_Detected /= 1 then
- Write_Char ('s');
- end if;
-
- Write_Char (')');
- end if;
- end if;
-
- Write_Eol;
- Set_Standard_Output;
+ Write_Error_Summary;
end if;
if Maximum_Messages /= 0 then