From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ghjuvan Lacambre <lacambre@adacore.com>
Subject: [Ada] Update output of verbose error summary
Date: Thu, 18 Jun 2020 05:13:20 -0400 [thread overview]
Message-ID: <20200618091320.GA2151@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 422 bytes --]
GNAT does not count warnings originating from a Compile_Time_Warning
pragma as an error anymore, even if the -gnatwe flag is provided. This
requires updating the output of its error summary.
Tested on x86_64-pc-linux-gnu, committed on trunk
2020-06-18 Ghjuvan Lacambre <lacambre@adacore.com>
gcc/ada/
* errout.adb (Write_Error_Summary): Display number of warnings
treated as errors.
* errutil.ads: Update comment.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 3900 bytes --]
--- gcc/ada/errout.adb
+++ gcc/ada/errout.adb
@@ -1870,30 +1870,77 @@ package body Errout is
Write_Str (" errors");
end if;
- if Warnings_Detected - Warning_Info_Messages /= 0 then
- Write_Str (", ");
- Write_Int (Warnings_Detected);
- Write_Str (" warning");
+ -- 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.
- if Warnings_Detected - Warning_Info_Messages /= 1 then
- Write_Char ('s');
- end if;
+ declare
+ Warnings_Count : constant Int :=
+ Warnings_Detected - Warning_Info_Messages;
+
+ 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.
- if Warning_Mode = Treat_As_Error then
- Write_Str (" (treated as error");
+ begin
+ if Warnings_Count > 0 then
+ Write_Str (", ");
+ Write_Int (Warnings_Count);
+ Write_Str (" warning");
- if Warnings_Detected /= 1 then
+ if Warnings_Count > 1 then
Write_Char ('s');
end if;
- Write_Char (')');
+ 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");
- elsif Warnings_Treated_As_Errors /= 0 then
- Write_Str (" (");
- Write_Int (Warnings_Treated_As_Errors);
- Write_Str (" treated as errors)");
+ 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;
+ end;
if Warning_Info_Messages + Report_Info_Messages /= 0 then
Write_Str (", ");
--- gcc/ada/errutil.ads
+++ gcc/ada/errutil.ads
@@ -30,8 +30,7 @@
-- Err_Vars. Like Errout, it also uses the common variables and routines
-- in package Erroutc.
--- This package is used by the preprocessor (gprep.adb) and the project
--- manager (prj-err.ads).
+-- This package is used by the preprocessor (gprep.adb).
with Styleg;
with Types; use Types;
reply other threads:[~2020-06-18 9:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200618091320.GA2151@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=lacambre@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).