Skip to content

A list of compiler warning flags for different GCC and clang versions

License

Unknown, GPL-3.0 licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

Barro/compiler-warnings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 documentation provides reference for some of the diagnostic flags in Clang.

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:

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:

Some GCC 5 and 6 -Wall differences shown with meld

Development Build Status

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.

About

A list of compiler warning flags for different GCC and clang versions

Resources

License

Unknown, GPL-3.0 licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published