diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-07-14 13:44:33 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-07-17 07:51:23 +0000 |
commit | be2b3c91ae4ddb97c35237da11b350c99cc6fd3b (patch) | |
tree | 30e177b9f5a019b639966a13834c2d7fd2196594 /src/libs | |
parent | c9301e80bb960ba5df93fdd22932257542693154 (diff) |
Add Q_FALLTHROUGH for Qt < 5.8
... and make use of it.
With gcc 7, the new option -Wimplicit-fallthrough is introduced and
added to the -Wextra set, triggering dozens of warnings in our sources.
Therefore, we annotate all obviously intended fall-throughs. The ones
that are still left are unclear and need to be checked by the respective
maintainer.
Change-Id: I44ead33cd42a4b41c28ee5fcb5a31db272710bbc
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.cpp | 4 | ||||
-rw-r--r-- | src/libs/utils/qtcfallthrough.h | 54 | ||||
-rw-r--r-- | src/libs/utils/utils-lib.pri | 1 | ||||
-rw-r--r-- | src/libs/utils/utils.qbs | 1 |
4 files changed, 59 insertions, 1 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 8754206a0b..16f351077a 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -27,6 +27,8 @@ #include "ObjectiveCTypeQualifiers.h" #include "QtContextKeywords.h" +#include <utils/qtcfallthrough.h> + #include <unordered_map> #include <utility> @@ -442,7 +444,7 @@ bool Parser::skipUntilStatement() case T_AT_THROW: if (_languageFeatures.objCEnabled) return true; - + Q_FALLTHROUGH(); default: consumeToken(); } diff --git a/src/libs/utils/qtcfallthrough.h b/src/libs/utils/qtcfallthrough.h new file mode 100644 index 0000000000..6eba622837 --- /dev/null +++ b/src/libs/utils/qtcfallthrough.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QtGlobal> + +#ifndef Q_FALLTHROUGH +#ifndef QT_HAS_CPP_ATTRIBUTE +#ifdef __has_cpp_attribute +# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#else +# define QT_HAS_CPP_ATTRIBUTE(x) 0 +#endif +#endif +#if defined(__cplusplus) +#if QT_HAS_CPP_ATTRIBUTE(fallthrough) +# define Q_FALLTHROUGH() [[fallthrough]] +#elif 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 +# if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL) +# define Q_FALLTHROUGH() __attribute__((fallthrough)) +# else +# define Q_FALLTHROUGH() (void)0 +#endif +#endif +#endif diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index bfc9d6084e..3a6aa0a09a 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -239,6 +239,7 @@ HEADERS += \ $$PWD/asconst.h \ $$PWD/smallstringfwd.h \ $$PWD/optional.h \ + $$PWD/qtcfallthrough.h \ $$PWD/../3rdparty/optional/optional.hpp FORMS += $$PWD/filewizardpage.ui \ diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 559129df16..6d68683fdd 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -175,6 +175,7 @@ Project { "proxycredentialsdialog.cpp", "proxycredentialsdialog.h", "proxycredentialsdialog.ui", + "qtcfallthrough.h", "qtcassert.cpp", "qtcassert.h", "qtcolorbutton.cpp", |