Skip to content

Commit 4daaf2c

Browse files
danmarDaniel Marjamäki
authored andcommitted
Fix #14850 (Compilation fails on oraclelinux:8 (g++ 8.5.0 released in 2021)) (#8654)
1 parent e73bf44 commit 4daaf2c

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

lib/checks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ namespace CheckInstances
2929
{
3030
/** List of registered check classes. This is used by Cppcheck to run checks and generate documentation */
3131
CPPCHECKLIB const std::list<Check *>& get();
32-
};
32+
}
3333

3434
#endif // checksH

lib/settings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Settings::~Settings() = default;
7878
Settings::Settings(const Settings&) = default;
7979
Settings & Settings::operator=(const Settings &) = default;
8080

81-
Settings::Settings(Settings&&) noexcept = default;
82-
Settings & Settings::operator=(Settings &&) noexcept = default;
81+
Settings::Settings(Settings&&) CPPCHECK_NOEXCEPT = default;
82+
Settings & Settings::operator=(Settings &&) CPPCHECK_NOEXCEPT = default;
8383

8484
std::string Settings::loadCppcheckCfg(Settings& settings, Suppressions& suppressions, bool debug)
8585
{

lib/settings.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ class SimpleEnableGroup {
9494
};
9595

9696

97+
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 9
98+
// Hack to workaround GCC bug.
99+
// Details: https://trac.cppcheck.net/ticket/14850
100+
// seen on g++ before 10.x
101+
#define CPPCHECK_NOEXCEPT
102+
#else
103+
#define CPPCHECK_NOEXCEPT noexcept
104+
#endif
105+
106+
97107
/**
98108
* @brief This is just a container for general settings so that we don't need
99109
* to pass individual values to functions or constructors now or in the
@@ -113,8 +123,8 @@ class CPPCHECKLIB WARN_UNUSED Settings {
113123
Settings(const Settings&);
114124
Settings& operator=(const Settings&);
115125

116-
Settings(Settings&&) noexcept;
117-
Settings& operator=(Settings&&) noexcept;
126+
Settings(Settings&&) CPPCHECK_NOEXCEPT;
127+
Settings& operator=(Settings&&) CPPCHECK_NOEXCEPT;
118128

119129
static std::string loadCppcheckCfg(Settings& settings, Suppressions& suppressions, bool debug = false);
120130

0 commit comments

Comments
 (0)