From 7eddca359dd30d1dcfabb519f60ac4be83eda02c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 7 Oct 2016 10:38:42 +0200 Subject: [PATCH] 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 --- src/corelib/global/qcompilerdetection.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index a3d816f0c3..dcdddeb04d 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -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