summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-07-11 12:22:50 +0200
committerhjk <hjk121@nokiamail.com>2014-07-23 07:45:22 +0200
commit9782938045c33b37fe0bbb6cdf00e406cd3d837e (patch)
tree8ccf5182c0006f53f3e8354f74d38f10add3b4c3 /src
parente46d72751ba8188dfc37ad0e8e76198525f8d1f2 (diff)
Introduce Q_DECL_UNUSED_MEMBER for clang
Since version 3.2, clang warns about unused member variables (-Wunused-private-field). Marking such members with Q_DECL_UNUSED_MEMBER will silence this warning. This is a cleaner way than using Q_UNUSED() somewhere in the class methods (like we did previously in qloggingcategory.cpp). It mirrors Q_DECL_UNUSED for unused variables, which however can't be used unconditionally for member variables because e.g. gcc will complain. Change-Id: I2afff683a7c3bae3bdcd684e5085a643887bb2a0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: hjk <hjk121@nokiamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qcompilerdetection.h12
-rw-r--r--src/corelib/io/qloggingcategory.cpp4
-rw-r--r--src/corelib/io/qloggingcategory.h6
3 files changed, 15 insertions, 7 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 24c5bfa741..693d7e5c75 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Copyright (C) 2012 Intel Corporation
** Contact: http://www.qt-project.org/legal
**
@@ -705,6 +705,13 @@
# define Q_COMPILER_VLA
# endif
# endif
+
+# if defined(__has_warning)
+# if __has_warning("-Wunused-private-field")
+# define Q_DECL_UNUSED_MEMBER Q_DECL_UNUSED
+# endif
+# endif
+
#endif // Q_CC_CLANG
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
@@ -996,6 +1003,9 @@
#ifndef Q_DECL_UNUSED
# define Q_DECL_UNUSED
#endif
+#ifndef Q_DECL_UNUSED_MEMBER
+# define Q_DECL_UNUSED_MEMBER
+#endif
#ifndef Q_FUNC_INFO
# if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC)
# define Q_FUNC_INFO __FILE__ "(line number unavailable)"
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp
index 92ac9d925f..0f2c7de053 100644
--- a/src/corelib/io/qloggingcategory.cpp
+++ b/src/corelib/io/qloggingcategory.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -191,8 +191,6 @@ QLoggingCategory::QLoggingCategory(const char *category)
: d(0),
name(0)
{
- Q_UNUSED(d);
- Q_UNUSED(placeholder);
enabled.store(0x01010101); // enabledDebug = enabledWarning = enabledCritical = true;
const bool isDefaultCategory
diff --git a/src/corelib/io/qloggingcategory.h b/src/corelib/io/qloggingcategory.h
index 573af2105c..2025911e2c 100644
--- a/src/corelib/io/qloggingcategory.h
+++ b/src/corelib/io/qloggingcategory.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -80,7 +80,7 @@ public:
static void setFilterRules(const QString &rules);
private:
- void *d; // reserved for future use
+ Q_DECL_UNUSED_MEMBER void *d; // reserved for future use
const char *name;
#ifdef Q_BIG_ENDIAN
@@ -100,7 +100,7 @@ private:
AtomicBools bools;
QBasicAtomicInt enabled;
};
- bool placeholder[4]; // reserve for future use
+ Q_DECL_UNUSED_MEMBER bool placeholder[4]; // reserved for future use
};
#define Q_DECLARE_LOGGING_CATEGORY(name) \