public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Update output of verbose error summary
@ 2020-06-18  9:13 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-06-18  9:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ghjuvan Lacambre

[-- 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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-18  9:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18  9:13 [Ada] Update output of verbose error summary Pierre-Marie de Rodat

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).