diff options
author | Nico Weber <nicolasweber@gmx.de> | 2018-10-24 15:34:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-24 15:34:43 (GMT) |
commit | fccab7408a53b936fe1a6a527746a5119be71c66 (patch) | |
tree | c58f35a8d50e7516211f4dc82d40e37720cfa5b8 /src/util.h | |
parent | d2045dedc39885e702176b2b5e05bc77024ae3aa (diff) | |
parent | 08ef815c7b55f28417b1a965eeab3640558d5f5a (diff) | |
download | Ninja-fccab7408a53b936fe1a6a527746a5119be71c66.zip Ninja-fccab7408a53b936fe1a6a527746a5119be71c66.tar.gz Ninja-fccab7408a53b936fe1a6a527746a5119be71c66.tar.bz2 |
Merge pull request #1417 from stefanb2/topic-silence-gcc-fallthrough-warnings
Silence GCC -Wimplicit-fallthrough warnings
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -34,6 +34,20 @@ using namespace std; /// Log a fatal message and exit. NORETURN void Fatal(const char* msg, ...); +// Have a generic fall-through for different versions of C/C++. +#if defined(__cplusplus) && __cplusplus >= 201703L +#define NINJA_FALLTHROUGH [[fallthrough]] +#elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__clang__) +#define NINJA_FALLTHROUGH [[clang::fallthrough]] +#elif defined(__cplusplus) && __cplusplus >= 201103L && defined(__GNUC__) && \ + __GNUC__ >= 7 +#define NINJA_FALLTHROUGH [[gnu::fallthrough]] +#elif defined(__GNUC__) && __GNUC__ >= 7 // gcc 7 +#define NINJA_FALLTHROUGH __attribute__ ((fallthrough)) +#else // C++11 on gcc 6, and all other cases +#define NINJA_FALLTHROUGH +#endif + /// Log a warning message. void Warning(const char* msg, ...); |