GCC Warnings Tools
Overview
show-gcc-warnings is a script which can extract information about all warnings supported by gcc in a convenient form, in order to know when support for each warning has been added or whether the given warning is already enabled by some other option (such as -Wall or -Wextra) or needs to be explicitly enabled.
Here is an example of using it:
$ ./show-gcc-warnings --cpp /path/to/gcc/repository > warnings.cpp
Here are the results generated by this script:
- For the warnings not enabled by another warning option.
- For all gcc warnings.
Download
The script is available from gcc-warnings-tools GitHub repository and there is no installation required but you must have a working Raku installation, see the requirements section below.
Requirements
You need a working installation of Raku and a Git checkout of gcc repository (which takes ~5GiB as of time of this writing, i.e. gcc 11).
Usage Instructions
Run ./show-gcc-warnings $GCC_DIR > warnings.csv
to generate
the CSV file containing all warnings not enabled by default or by one of the
common warning options and the minimum version in which they appeared (note
that 4.6.0 means that the warning was already present in gcc 4.6.0, not
necessarily that it was introduced in this version). With --all
option, all warnings are included and the extra "Enabled by" column is added
to show the condition enabling the warning.
If JSON::Fast
Raku module is available, specify --json
option to obtain output
in JSON format.
Alternatively, use --cpp
option to generate C++ fragment, which
can be included in the source of a program that needs to do something (e.g.
turn on) all the warnings.
Finally, --markdown
option can be used to generate a Markdown
table with the options.
If --dump-all-to
option is given, output files named
x.y.z
for all gcc releases since 4.6.0 containing all (not
enabled by default) warnings available in the given compiler version will be
created under the specified output directory $OUT_DIR
. The
existing files in this directory will not be overwritten. Further
specifying --only-version=x.y.z[,x2.y2.z2...]
will restrict the
output to the specified version(s) only. These files can be used on their own,
and can also be reused by specifing --read-from
option with the
same directory later when running in the default mode.
The helper dump-gcc-warnings
script can be used to produce more
detailed output, including the warnings enabled by default, if
--all
option is specified, for a particular gcc version, by
passing it common.opt
and c-family/c.opt
files from
gcc source tree as command line parameters.
Note that, for convenience,
output of the scripts for all gcc versions up to the latest tested one
(currently 10.2) are provided directly in this repository, see
warnings.{cpp,csv,json}
files and gcc
and
gcc-all
directories, containing per-directory warnings lists.
License
This script is Free Software released under BSD license.