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>
parent
8cec5e9a34
commit
5322200076
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue