Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
7acfbcc1
Commit
7acfbcc1
authored
6 years ago
by
Samuel Jackson
Browse files
Options
Downloads
Patches
Plain Diff
Add clang support to warning suppressions
parent
1e7010fc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/Kernel/inc/MantidKernel/WarningSuppressions.h
+67
-32
67 additions, 32 deletions
Framework/Kernel/inc/MantidKernel/WarningSuppressions.h
with
67 additions
and
32 deletions
Framework/Kernel/inc/MantidKernel/WarningSuppressions.h
+
67
−
32
View file @
7acfbcc1
...
@@ -31,61 +31,96 @@
...
@@ -31,61 +31,96 @@
* in a controlled manner. The work is based on
* in a controlled manner. The work is based on
* http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html
* http://dbp-consulting.com/tutorials/SuppressingGCCWarnings.html
*/
*/
// Currently this is only defined for gcc
#if defined(__clang__)
#if defined(__GNUC__) && !(defined(__INTEL_COMPILER))
#define CLANG_VERSION ((__clang_major__ * 100) + __clang_minor__)
// how to use a pragma in a macro
#endif
#define PRAGMA(x) _Pragma(#x)
// convenience for getting gcc version
#if defined(__GNUC__) && !(defined(__INTEL_COMPILER)) && !defined(__clang__)
#define GCC_VERSION \
#define GCC_VERSION \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
// Currently this is only defined for gcc
#if defined(GCC_VERSION) || defined(CLANG_VERSION)
// how to use a pragma in a macro
#define PRAGMA(x) _Pragma(#x)
// things to make the macros clearer
// things to make the macros clearer
#define
GCC_
DIAG_STR(s) #s
#define DIAG_STR(s) #s
// undefine definition from Poco 1.6
// undefine definition from Poco 1.6
#ifdef
GCC_
DIAG_JOINSTR
#ifdef DIAG_JOINSTR
#undef
GCC_
DIAG_JOINSTR
#undef DIAG_JOINSTR
#endif
#endif
#define
GCC_
DIAG_JOINSTR(x, y)
GCC_
DIAG_STR(x##y)
#define DIAG_JOINSTR(x, y) DIAG_STR(x##y)
// undefine definition from Poco 1.6
// undefine definition from Poco 1.6
#ifdef GCC_DIAG_DO_PRAGMA
#ifdef DIAG_DO_PRAGMA
#undef GCC_DIAG_DO_PRAGMA
#undef DIAG_DO_PRAGMA
#endif
#define DIAG_DO_PRAGMA(x) _Pragma(#x)
#if defined(GCC_VERSION)
#define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
#else
#define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
#endif
#endif
#define GCC_DIAG_DO_PRAGMA(x) _Pragma(#x)
#define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
// the following were previously defined in Poco/Platform_POSIX.h
// the following were previously defined in Poco/Platform_POSIX.h
#ifdef GCC_DIAG_ON
#ifdef DIAG_ON
#undef GCC_DIAG_ON
#undef DIAG_ON
#endif
#ifdef DIAG_OFF
#undef DIAG_OFF
#endif
#endif
#ifdef GCC_DIAG_OFF
#undef GCC_DIAG_OFF
#if defined(GCC_VERSION)
// define macros for turning the warning suppression on/off for GCC
// note that we turn off unknown warnings here as well so that we can use the
// same macro for GCC and clang.
#if GCC_VERSION >= 40600 // GCC 4.6.0
#define DIAG_OFF(x) \
DIAG_PRAGMA(push) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning)) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, x))
#define DIAG_ON(x) DIAG_PRAGMA(pop)
#else
#define DIAG_OFF(x) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning)) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, x))
#define DIAG_ON(x) \
DIAG_PRAGMA(warning DIAG_JOINSTR(-W, unknown-warning)) \
DIAG_PRAGMA(warning DIAG_JOINSTR(-W, x))
#endif
#endif
// define macros for turning the warning suppression on/off
#if GCC_VERSION >= 40600 // 4.6.0
#elif defined(CLANG_VERSION) && CLANG_VERSION >= 306
#define GCC_DIAG_OFF(x) \
// define macros for turning the warning suppression on/off for clang
GCC_DIAG_PRAGMA(push) \
// note that we turn off unknown warnings here as well so that we can use the
GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W, x))
// same macro for GCC and clang.
#define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(pop)
#define DIAG_OFF(x) \
DIAG_PRAGMA(push) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, unknown-warning-option)) \
DIAG_PRAGMA(ignored DIAG_JOINSTR(-W, x))
#define DIAG_ON(x) DIAG_PRAGMA(pop)
#else
#else
#define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W, x))
// neither clang or GCC
#define GCC_DIAG_ON(x) GCC_DIAG_PRAGMA(warning GCC_DIAG_JOINSTR(-W, x))
#define DIAG_OFF(x)
#define DIAG_ON(x)
#endif
#endif
#else // anything else - does nothing
#define GCC_DIAG_OFF(x)
#define GCC_DIAG_ON(x)
#endif
#endif
// Defining this macro separately since clang-tidy tries to add spaces around
// Defining this macro separately since clang-tidy tries to add spaces around
// the hyphen and we use it in a lot of test files.
// the hyphen and we use it in a lot of test files.
// clang-format off
// clang-format off
#if defined(__cplusplus) && defined(GCC_VERSION) && GCC_VERSION >= 50000
#if defined(__cplusplus) && defined(GCC_VERSION) && GCC_VERSION >= 50000
#define GCC_DIAG_OFF_SUGGEST_OVERRIDE GCC_DIAG_OFF(suggest-override)
#define DIAG_OFF_SUGGEST_OVERRIDE DIAG_OFF(suggest-override)
#define GCC_DIAG_ON_SUGGEST_OVERRIDE GCC_DIAG_ON(suggest-override)
#define DIAG_ON_SUGGEST_OVERRIDE DIAG_ON(suggest-override)
#elif defined(__cplusplus) && defined(CLANG_VERSION) && CLANG_VERSION >= 306
#define DIAG_OFF_SUGGEST_OVERRIDE DIAG_OFF(inconsistent-missing-override)
#define DIAG_ON_SUGGEST_OVERRIDE DIAG_ON(inconsistent-missing-override)
#else
#else
#define
GCC_
DIAG_OFF_SUGGEST_OVERRIDE
#define DIAG_OFF_SUGGEST_OVERRIDE
#define
GCC_
DIAG_ON_SUGGEST_OVERRIDE
#define DIAG_ON_SUGGEST_OVERRIDE
#endif
#endif
// clang-format on
// clang-format on
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment