Q_FALLTHROUGH: use GCC extensions in non-C++17-code

GCC defines the [[gnu::fallthrough]] attribute for C++11 and C++14
code, as well as __attribute__((fallthrough)) for C++98 and C code.

Use them.

Change-Id: I66aa178c2a96e2ff9ac3f6f02821c978b4ec3696
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Marc Mutz 2016-10-07 10:38:42 +02:00
parent 0a71cc111a
commit 7eddca359d

View File

@ -1351,10 +1351,16 @@
/* Clang can not parse namespaced attributes in C mode, but defines __has_cpp_attribute */
# if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
# define Q_FALLTHROUGH() [[clang::fallthrough]]
# elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
# define Q_FALLTHROUGH() [[gnu::fallthrough]]
# endif
#endif
#ifndef Q_FALLTHROUGH
# define Q_FALLTHROUGH() (void)0
# if defined(Q_CC_GNU) && Q_CC_GNU >= 700
# define Q_FALLTHROUGH() __attribute__((fallthrough))
# else
# define Q_FALLTHROUGH() (void)0
#endif
#endif