]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Handle Warnings_As_Errors the same way.
authorViljar Indus <indus@adacore.com>
Fri, 2 May 2025 10:04:55 +0000 (13:04 +0300)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 1 Jul 2025 08:29:41 +0000 (10:29 +0200)
commit4a7010db26e49f965c9196f6cbbc01d82af31fa8
treeeb078403cd11c3304a2e2981c89a67cf6885ef7c
parentb55ca90e276d724aea4aea8d924af54d23a99996
ada: Handle Warnings_As_Errors the same way.

There are multiple scenarios where warnings can be turned into
errors. However internally they should always be handled the
same way and we should not rely on additional counters and variables
to handle the different behaviours.

These different types of converted warnings have however been
emitted differently historically. This information is stored in
the Warn_Err attribute which now stores the reason for the conversion
so that the printers know how to handle those scenarios.

Based on the reason these warnings are printed in different ways:
* If converted by pragma Warning_As_Error then it should print the
message with an error prefix and a [warning-as-error] tag.
* If it is a run time warning converted by -gnatwE then the message
should be printed with just an error prefix.
* if the warning was converted by -gnatwe then the message should be
printed with a warning prefix.

gcc/ada/ChangeLog:

* atree.ads (Compile_Time_Pragma_Warnings): Removed.
* errout.adb (Initialize): Remove initialization for
Compile_Time_Pragma_Warnings.
(Error_Msg_Internal): Use Warning_As_Error_Kind in the
Error_Msg_Object. Set its value based on the reason the
warning was changed to an error.
(Write_JSON_Span): Adjust the code for Warn_Err.
(Output_Messages): Update the calculation for actual warnings
and errors by just using Warnings_Treated_As_Errors.
(Set_Msg_Text): Simply mark that we are dealing with a
run time message here. Move the code for the Warning_Mode to
Error_Msg_Internal.
* erroutc-pretty_emitter.adb (Write_Error_Msg_Line): Adjust the code
for Warn_Err. Use the Warn_As_Err_Tag token.
* erroutc.adb (Compilation_Errors): Simplify the implementation so
that it only checks for errors and warnings treated as errors.
(Decrease_Error_Msg_Count): Remove the count for
Compile_Time_Pragma_Warnings.
(dmsg): Adjust the code for changes to Warn_Err.
(Increase_Error_Msg_Count): Likewise and remove the count for
Compile_Time_Pragma_Warnings.
(Output_Msg_Text): Warnings converted to error by the
Warning_As_Error pragma and -gnatwE now use the error prefix
in their messages but only warnings changed by the pragma get
the [warning-as-error] tag.
(Output_Text_Within): Adjust the variable name for
Is_Runtime_Raise_Msg.
(Write_Error_Summary): Adjust printing of warnings so that it
just uses the counts for Warnings_Detected and
Warnings_Treated_As_Errors.
* erroutc.ads (Is_Runtime_Raise): renamed to Is_Runtime_Raise_Msg.
(Warning_As_Error_Kind): New type for marking the warning message
is treated as an error which also captures the reason for the
change. Historically each of the reasons will have a different way
of displaying the warning message.
(Error_Msg_Object.Warn_Err): Change type to Warning_As_Error_Kind.
(Kind_To_String): Warnings treated as errors originating from
the pragma or -gnatwE will return error where as warnings
originating from -gnatwe will return warning.
(Compilation_Errors): Update the documentation.
(Warn_As_Err_Tag): Constant string to be used when printing warnings
as errors.
* errutil.adb (Error_Msg): Adjust the code for Warn_Err.
gcc/ada/atree.ads
gcc/ada/errout.adb
gcc/ada/erroutc-pretty_emitter.adb
gcc/ada/erroutc.adb
gcc/ada/erroutc.ads
gcc/ada/errutil.adb