diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-06-28 14:43:27 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-01 06:58:36 +0100 |
commit | dd987a9ef08933b970387dac1f9bdd930ca9656c (patch) | |
tree | 23bfe015a08ec2c41e7e9e18112e104ea34af5e6 /src/corelib/global/qflags.h | |
parent | 9c9f609313b6a0ddf8e226b291324c97b504d07f (diff) |
Add other integer overloads to QFlag's constructor
This avoids "change of sign" warnings as found by ICC when the high
bit is set. This often happens when you do
X & ~Y
as ~Y probably has bit 31 on. If the enum is unsigned, then there's a sign conversion.
Change-Id: Ia5f221d928ac0155f4504a70c4046e60c25fbf3b
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qflags.h')
-rw-r--r-- | src/corelib/global/qflags.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index dd4222b89f..9e97724fec 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -53,13 +53,19 @@ class QFlag { int i; public: - Q_DECL_CONSTEXPR inline QFlag(int i); +#if !defined(__LP64__) && !defined(Q_QDOC) + Q_DECL_CONSTEXPR inline QFlag(long ai) : i(int(ai)) {} + Q_DECL_CONSTEXPR inline QFlag(ulong ai) : i(int(long(ai))) {} +#endif + Q_DECL_CONSTEXPR inline QFlag(int ai) : i(ai) {} + Q_DECL_CONSTEXPR inline QFlag(uint ai) : i(int(ai)) {} + Q_DECL_CONSTEXPR inline QFlag(short ai) : i(int(ai)) {} + Q_DECL_CONSTEXPR inline QFlag(ushort ai) : i(int(uint(ai))) {} Q_DECL_CONSTEXPR inline operator int() const { return i; } + Q_DECL_CONSTEXPR inline operator uint() const { return uint(i); } }; Q_DECLARE_TYPEINFO(QFlag, Q_PRIMITIVE_TYPE); -Q_DECL_CONSTEXPR inline QFlag::QFlag(int ai) : i(ai) {} - class QIncompatibleFlag { int i; |