diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2015-03-31 15:17:57 +0200 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2015-04-01 14:20:50 +0000 |
commit | 5322200076c95ca3db32481e1f035d7785ce88ae (patch) | |
tree | 356925b117e8efec11cf7273d1529144fabe2520 /src/corelib/kernel | |
parent | 8cec5e9a34812eea3d4e2182f0feed91e85a1eb3 (diff) |
Silence clang warnings in C++03 mode
C++03 forbid the use of local or unnamed type as template parameter.
But in C++11 that is allowed, and clang accept them even in C++03
mode, but with a warning.
The Warning happen for example with this code:
enum { Foo = 3 };
int x = 3 << Foo;
Then the compiler issues warnings:
metatype.h:1379:31: warning: template argument uses local type [-Wlocal-type-template-args]
enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) };
^~~~~~~~~~~~~~~~~~~~
qdebug.h:269:42: note: in instantiation of template class 'QtPrivate::IsQEnumHelper<(anonymous enum)>' requested here
typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug dbg, T value)
Normaly the compiler should not even try to instantiate the operator<<
with such types in C++03 mode.
Change-Id: I48c7d5d1836fd87986835fe15c7e0b1beb73c728
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 55f8fc9b2c..aa8d826ed9 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1364,6 +1364,11 @@ namespace QtPrivate enum { Value = sizeof(checkType(static_cast<T*>(0))) == sizeof(void*) }; }; + +QT_WARNING_PUSH +// In C++03 mode, clang consider local or unnamed type and throw a warning instead of ignoring them +QT_WARNING_DISABLE_CLANG("-Wunnamed-type-template-args") +QT_WARNING_DISABLE_CLANG("-Wlocal-type-template-args") template<typename T> char qt_getEnumMetaObject(const T&); template<typename T> @@ -1375,6 +1380,7 @@ namespace QtPrivate // qt_getEnumMetaObject(T) which returns 'char' enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) }; }; +QT_WARNING_POP template<typename T, typename Enable = void> struct MetaObjectForType |