From ac9be327f8dc788a964b77c6bcdf0391c85c9cbd Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Sep 2012 15:06:11 +0200 Subject: QFlags: use unsigned int when the enum's underlying is unsigned Replace storage and operator int() return types with unsigned int if the enum is unsigned. This fixes a number of exisiting warnings, in particular with Qt::MouseButton under GCC. Change-Id: Ia12d36212329aec3e9d62a5fbd38809a6c2b36d0 Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qflags/tst_qflags.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tests/auto/corelib/global/qflags') diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index f608dd6f93..215462606b 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -48,6 +48,7 @@ private slots: void testFlagZeroFlag() const; void testFlagMultiBits() const; void constExpr(); + void signedness(); }; void tst_QFlags::testFlag() const @@ -123,10 +124,23 @@ void tst_QFlags::constExpr() #endif } +void tst_QFlags::signedness() +{ + // these are all 'true' on GCC, but since the std says the + // underlying type is implementation-defined, we need to allow for + // a different signedness, so we only check that the relative + // signedness of the types matches: + Q_STATIC_ASSERT((QtPrivate::is_unsigned::value == + QtPrivate::is_unsigned::value)); + + Q_STATIC_ASSERT((QtPrivate::is_signed::value == + QtPrivate::is_signed::value)); +} + // (statically) check QTypeInfo for QFlags instantiations: enum MyEnum { Zero, One, Two, Four=4 }; -Q_DECLARE_FLAGS( MyFlags, MyEnum ); -Q_DECLARE_OPERATORS_FOR_FLAGS( MyFlags ); +Q_DECLARE_FLAGS( MyFlags, MyEnum ) +Q_DECLARE_OPERATORS_FOR_FLAGS( MyFlags ) Q_STATIC_ASSERT( !QTypeInfo::isComplex ); Q_STATIC_ASSERT( !QTypeInfo::isStatic ); -- cgit v1.2.3