C/C++/Objective-C compiler warning flags collection and parsers
This project includes tools and lists to figure out all warning flags that clang compiler and GNU Compiler Collection have for C family languages (C, C++, and Objective-C). This also shows all aliases and warning flags that a certain flag enables (prefixed with "#" character) so that you can easily see which flag is enabled by what. There are also warning flags that do nothing for compatibility or deprecation reasons. They are suffixed with "# DUMMY switch" text.
The purpose of these collections is to make it more easy to use the static code analysis tools that compilers provide.
Clang warning flags
Clang includes -Weverything
flag, that is not shown in these lists,
that enables all warnings.
- clang 4.0 all • top level • unique • diff
- clang 3.9 all • top level • unique • diff
- clang 3.8 all • top level • unique • diff
- clang 3.7 all • top level • unique • diff
- clang 3.6 all • top level • unique • diff
- clang 3.5 all • top level • unique • diff
- clang 3.4 all • top level • unique • diff
- clang 3.3 all • top level • unique • diff
- clang 3.2 all • top level • unique
GCC warning flags
If you need a full list of
GCC warning options,
for a specific version of GCC that you have, you can run GCC with gcc --help=warnings
to get that list. Otherwise some plain GCC warning
options lists are available below:
- GCC 7 all • top level • unique • diff
- GCC 6 all • top level • unique • diff
- GCC 5 all • top level • unique • diff
- GCC 4.9 all • top level • unique • diff
- GCC 4.8 all • top level • unique • diff
- GCC 4.7 all • top level • unique • diff
- GCC 4.6 all • top level • unique • diff
- GCC 4.5 all • top level • unique • diff
- GCC 4.4 all • top level • unique • diff
- GCC 4.3 all • top level • unique • diff
- GCC 4.2 all • top level • unique • diff
- GCC 4.1 all • top level • unique • diff
- GCC 4.0 all • top level • unique • diff
- GCC 3.4 all • top level • unique (first GCC with domain specific language options file)
Examining differences
One use case for these kinds of lists is to see what differences there are between different compilers and compiler versions. I have made available rudimentary compiler flag differences between two consequent compiler versions as diff-files, but for more specific differences you need to use some (visual) diff program, as shown below:
Development
This uses ANTLR as a parser generator with some supporting Python code to parse warning flags from actual compiler option data files. Other requirements are following (plus their dependencies):
Building
After you have installed all the requirements and are able to run
ANTLR with antlr4
command, just use following commands in parsers/
directory to generate these lists yourself:
ninja
./parse-clang-diagnostic-groups.py <path-to-clang-source>/include/clang/Basic/DiagnosticGroups.td
./parse-gcc-warning-options.py <path-to-gcc-source>/gcc/{common.opt,c-family/c.opt}
And you'll get the list of all individual warning flags and their dependencies that are in the requested compiler version.
To generate filtered lists, you may use --top-level
and --unique
switches.
--top-level
switch does not include warnings that are enabled by some other switch in the list.--unique
lists all warnings without any information what other warnings they enable. Diffs on this page are created from these files.
Tests
There are some unit tests testing the low level functionality. You may
run time with ninja test
command in parsers/
directory to verify
that unit tests pass.
Processing git repositories
When parser gets a change that affects formatting or other output for
multiple files these warning lists need to be recreated. There are
process-clang-git.sh
and process-gcc-git.sh
scripts that take the
git repository root as their first parameter and apply all different
variants of these commands to create final text files.