]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Pragma Warning_As_Error works for style warnings
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Aug 2019 09:48:51 +0000 (09:48 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 20 Aug 2019 09:48:51 +0000 (09:48 +0000)
commit6b466b3442b22ffd497407824c4b485fb89d1828
tree73b01db9d46ba069cf32333cb74682a3952538c6
parentc20c73fab8baa36ccbbe53857c390a36ee0271ee
[Ada] Pragma Warning_As_Error works for style warnings

Pragma Warning_As_Error now works for style warnings (messages that
start with "(style)", enabled by -gnaty) the same way it works for
regular warnings enabled by -gnatw.

The following test should fail to build with style checks:

gnat.adc:

pragma Warning_As_Error ("two spaces required");

style.adb:

procedure Style is
   X : Integer;
begin
   null;
   --Hello
end;

gnatmake -q -f -g style.adb -gnaty

should get:

style.adb:2:04: warning: variable "X" is never read and never assigned
style.adb:5:06: error: (style) two spaces required [warning-as-error]
style.adb:6:01: (style) "end Style" required
gnatmake: "style.adb" compilation error

and no executable should be created.

2019-08-20  Bob Duff  <duff@adacore.com>

gcc/ada/

* errout.adb (Error_Msg_Internal): Set Warn_Err in case of
Is_Style_Msg.
* erroutc.adb (Output_Msg_Text): Do Warnings_Treated_As_Errors
processing and [warning-as-error] modification for style
messages.  Clean up code, simplify, remove unnecessary block
statement, add renaming of table entry.
* erroutc.ads (Warning_Treated_As_Error): Fix comment: no such
thing as Set_Warning_As_Error.
* opt.ads: Clean up comments and move related declarations near
each other.
* par-prag.adb: Process Warning_As_Error. This is necessary
because many style warning happen during parsing.
* sem_prag.adb: Use new Acquire_Warning_Match_String.
* sem_util.ads, sem_util.adb (Acquire_Warning_Match_String): New
function shared by par-prag.adb and sem_prag.adb. Replaces the
procedure in sem_prag.adb. Avoid use of global variables.
* stringt.ads, stringt.adb (To_String): New function to convert
String_Id to String.
* doc/gnat_rm/implementation_defined_pragmas.rst: Document the
new feature.
* gnat_rm.texi: Regenerate.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274721 138bc75d-0d04-0410-961f-82ee72b054a4
13 files changed:
gcc/ada/ChangeLog
gcc/ada/doc/gnat_rm/implementation_defined_pragmas.rst
gcc/ada/errout.adb
gcc/ada/erroutc.adb
gcc/ada/erroutc.ads
gcc/ada/gnat_rm.texi
gcc/ada/opt.ads
gcc/ada/par-prag.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads
gcc/ada/stringt.adb
gcc/ada/stringt.ads