diff options
author | Ghjuvan Lacambre <lacambre@adacore.com> | 2020-04-23 11:26:54 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-18 05:08:33 -0400 |
commit | 4f4fd8ae2ce8ad7ccaf996d21ea7e82388bb0e23 (patch) | |
tree | 54f3d2a7dc01986c25d8e9a5c69343866068ecab | |
parent | 3874e79d94ef6b8adb99373f2780847633021d16 (diff) | |
download | gcc-4f4fd8ae2ce8ad7ccaf996d21ea7e82388bb0e23.zip gcc-4f4fd8ae2ce8ad7ccaf996d21ea7e82388bb0e23.tar.gz gcc-4f4fd8ae2ce8ad7ccaf996d21ea7e82388bb0e23.tar.bz2 |
[Ada] Update output of verbose error summary
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.
-rw-r--r-- | gcc/ada/errout.adb | 79 | ||||
-rw-r--r-- | gcc/ada/errutil.ads | 3 |
2 files changed, 64 insertions, 18 deletions
diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 993dddf..8c60a3f 100644 --- a/gcc/ada/errout.adb +++ b/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 (", "); diff --git a/gcc/ada/errutil.ads b/gcc/ada/errutil.ads index 705acbc..56bd242 100644 --- a/gcc/ada/errutil.ads +++ b/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; |