From 5322200076c95ca3db32481e1f035d7785ce88ae Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 31 Mar 2015 15:17:57 +0200 Subject: 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::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 --- src/corelib/kernel/qmetatype.h | 6 ++++++ 1 file changed, 6 insertions(+) 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(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 char qt_getEnumMetaObject(const T&); template @@ -1375,6 +1380,7 @@ namespace QtPrivate // qt_getEnumMetaObject(T) which returns 'char' enum { Value = sizeof(qt_getEnumMetaObject(declval())) == sizeof(QMetaObject*) }; }; +QT_WARNING_POP template struct MetaObjectForType -- cgit v1.2.3