The documentation for adding the results of compiler checks to Gnatcheck’s output says about Warnings (with some editing)
To record compiler warnings (see Warning Message Control section in GNAT User’s Guide), use the Warnings rule with a parameter that is a valid static_string_expression argument of the GNAT pragma Warnings (see “Pragma Warnings” in the GNAT Reference Manual). Note that [the]in case of gnatcheck s
parameter, that corresponds to the GNAT -gnatws
option, disables all the specific warnings, but [does] not suppresses the warning mode, and [the] e
parameter, corresponding to -gnatwe
that means "treat warnings as errors", does not have any effect.
If you go to look up "pragma Warnings” in the GNAT Reference Manual, you’ll find it sends you off to the compiler:
The string is a list of letters specifying which warnings are to be activated and which deactivated. The code for these letters is the same as the string used in the command line switch controlling warnings [-gnatw
]. For a brief summary, use the gnatmake command with no arguments, which will generate usage information containing the list of warnings switches supported.
Following this advice, there seems to be no -gnatwx
to give you the effect of -Wuninitialized
. However, if you turn on all warnings
project Checks is
for Source_Files use ("checks.adb");
package Check is
for Default_Switches ("ada") use
(
"-rules",
"+RWarnings:.e"
);
end Check;
end Checks;
and run it on
procedure Checks (Input : Integer; Result : out Integer) is
X : Integer;
Y : Integer;
Z : Integer;
begin
if (Y > 0) = True then
Result := X;
end if;
end Checks;
you get
checks.adb:1:19: warning: formal parameter "Input" is not referenced
checks.adb:2:04: warning: variable "X" is read but never assigned
checks.adb:3:04: warning: variable "Y" is read but never assigned
checks.adb:4:04: warning: variable "Z" is never read and never assigned
checks.adb:6:15: warning: comparison with True is redundant
where the warnings on lines 2, 3 (and 4) mean the same as “uninitialized”, I think.
You can then turn off the warnings you don’t want; for example, "+RWarnings:.eF”
will "turn off warnings for unreferenced formal”, and suppresses the warning on line 1.