This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Implement new pragma Warning_As_Error


This implements a new pragma Warning_As_Error which can be used to
specify that selected warnings are to be treated as errors. See
new documentation in GNAT RM for full details.

The pragma can appear either in a global configuration pragma file
(e.g. gnat.adc), or at the start of a file. Given a global
configuration pragma file containing:

pragma Warning_As_Error ("[-gnatwj]");

which will treat all obsolescent feature warnings as errors, the
following program compiles as shown (compile options here are
@option{-gnatwa.e -gnatld7 -gnatj60}).

     1. pragma Warning_As_Error ("*never assigned*");
     2. function Warnerr return String is
     3.    X : Integer;
           |
        >>> warning(error): variable "X" is never read and
            never assigned [-gnatwv]

     4.    Y : Integer;
           |
        >>> warning: variable "Y" is assigned but never
            read [-gnatwu]

     5.
     6. begin
     7.    Y := 0;
     8.    return %ABC%;
                  |
        >>> warning(error): use of "%" is an obsolescent
            feature (RM J.2(4)), use """ instead [-gnatwj]

     9. end;

 9 lines: No errors, 3 warnings (2 treated as errors)

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-02-25  Robert Dewar  <dewar@adacore.com>

	* atree.ads (Warnings_Treated_As_Errors): New variable.
	* errout.adb (Error_Msg_Internal): Set Warn_Err flag in
	error object (Initialize): Initialize Warnings_As_Errors_Count
	(Write_Error_Summary): Include count of warnings treated as errors.
	* erroutc.adb (Warning_Treated_As_Error): New function.
	(Matches): Function moved to outer level of package.
	* erroutc.ads (Error_Msg_Object): Add Warn_Err flag.
	(Warning_Treated_As_Error): New function.
	* gnat_rm.texi: Document pragma Treat_Warning_As_Error.
	* opt.adb: Add handling of Warnings_As_Errors_Count[_Config].
	* opt.ads (Config_Switches_Type): Add entry for
	Warnings_As_Errors_Count.
	(Warnings_As_Errors_Count): New variable.
	(Warnings_As_Errors): New array.
	* par-prag.adb: Add dummy entry for Warning_As_Error.
	* sem_prag.adb (Analyze_Pragma): Implement new pragma
	Warning_As_Error.
	* snames.ads-tmpl: Add entries for Warning_As_Error pragma.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]