summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-10-30 20:44:43 -0700
committerThiago Macieira <thiago.macieira@intel.com>2014-12-03 18:09:15 +0100
commit63a512023e861380f4489b103212769b741a93dc (patch)
treec4b324f0b2e257002b8c52e02d7db06b380b4796 /src
parent34b66aaf07af57bb11b9abae9fb175f650540f95 (diff)
Add macros for enabling/disabling warnings
This allows us to avoid the ugly #if for compiler versions. We might still need for when a warning only occurs in one compiler version, but otherwise the code will be much cleaner. Change-Id: Ibc941d898b3dad2e3d87c11378f29139c31f0fff Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qcompilerdetection.h46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index ee396409d8..dcd185742a 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Copyright (C) 2012 Intel Corporation
+** Copyright (C) 2014 Intel Corporation
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -1061,6 +1061,50 @@
#endif
/*
+ * Warning/diagnostic handling
+ */
+
+#define QT_DO_PRAGMA(text) _Pragma(#text)
+#if defined(Q_CC_INTEL)
+# define QT_WARNING_PUSH QT_DO_PRAGMA(warning(push))
+# define QT_WARNING_POP QT_DO_PRAGMA(warning(pop))
+# define QT_WARNING_DISABLE_INTEL(number) QT_DO_PRAGMA(warning(disable: number))
+# define QT_WARNING_DISABLE_MSVC(number)
+# define QT_WARNING_DISABLE_CLANG(text)
+# define QT_WARNING_DISABLE_GCC(text)
+#elif defined(Q_CC_MSVC) && _MSC_VER >= 1500
+# undef QT_DO_PRAGMA /* not needed */
+# define QT_WARNING_PUSH __pragma(warning(push))
+# define QT_WARNING_POP __pragma(warning(pop))
+# define QT_WARNING_DISABLE_MSVC(number) __pragma(warning(disable: number))
+# define QT_WARNING_DISABLE_INTEL(number)
+# define QT_WARNING_DISABLE_CLANG(text)
+# define QT_WARNING_DISABLE_GCC(text)
+#elif defined(Q_CC_CLANG)
+# define QT_WARNING_PUSH QT_DO_PRAGMA(clang diagnostic push)
+# define QT_WARNING_POP QT_DO_PRAGMA(clang diagnostic pop)
+# define QT_WARNING_DISABLE_CLANG(text) QT_DO_PRAGMA(clang diagnostic ignored text)
+# define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text) // GCC directives work in Clang too
+# define QT_WARNING_DISABLE_INTEL(number)
+# define QT_WARNING_DISABLE_MSVC(number)
+#elif defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 405)
+# define QT_WARNING_PUSH QT_DO_PRAGMA(GCC diagnostic push)
+# define QT_WARNING_POP QT_DO_PRAGMA(GCC diagnostic pop)
+# define QT_WARNING_DISABLE_GCC(text) QT_DO_PRAGMA(GCC diagnostic ignored text)
+# define QT_WARNING_DISABLE_CLANG(text)
+# define QT_WARNING_DISABLE_INTEL(number)
+# define QT_WARNING_DISABLE_MSVC(number)
+#else // All other compilers, GCC < 4.6 and MSVC < 2008
+# define QT_WARNING_DISABLE_GCC(text)
+# define QT_WARNING_PUSH
+# define QT_WARNING_POP
+# define QT_WARNING_DISABLE_INTEL(number)
+# define QT_WARNING_DISABLE_MSVC(number)
+# define QT_WARNING_DISABLE_CLANG(text)
+# define QT_WARNING_DISABLE_GCC(text)
+#endif
+
+/*
Proper for-scoping in MIPSpro CC
*/
#ifndef QT_NO_KEYWORDS