aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/errout.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/errout.adb')
-rw-r--r--gcc/ada/errout.adb79
1 files changed, 63 insertions, 16 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 (", ");