summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurl.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2013-09-16 22:24:45 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-07 03:06:06 +0100
commit1248b1cbe238616ab3a1dd79f65f76f92d256a6e (patch)
treebce2da8d691128b2861cb16e947d84d2d5ca60dc /src/corelib/io/qurl.h
parent6272a816d192b3c9b363164216bfd7a13e7370e9 (diff)
Q(UrlTwo)Flags: avoid undefined behavior
Loading an enum with a value that isn't in the enum is undefined, according to Clang's usan. So when doing logical operations on QFlags<E>, don't go through the QFlags(E) constructor, but via QFlags(QFlag) (=int) instead. Apply the same change to QUrlTwoFlags. Change-Id: I5f27e22c4d831482fcbba88b97cb124fb005e3fd Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qurl.h')
-rw-r--r--src/corelib/io/qurl.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 637eac87b6..76e3c0f8ca 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -86,33 +86,33 @@ public:
inline QUrlTwoFlags &operator^=(E1 f) { i ^= f; return *this; }
inline QUrlTwoFlags &operator^=(E2 f) { i ^= f; return *this; }
- Q_DECL_CONSTEXPR inline operator QFlags<E1>() const { return E1(i); }
- Q_DECL_CONSTEXPR inline operator QFlags<E2>() const { return E2(i); }
+ Q_DECL_CONSTEXPR inline operator QFlags<E1>() const { return QFlag(i); }
+ Q_DECL_CONSTEXPR inline operator QFlags<E2>() const { return QFlag(i); }
Q_DECL_CONSTEXPR inline operator int() const { return i; }
Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator|(QUrlTwoFlags f) const
- { return QUrlTwoFlags(E1(i | f.i)); }
+ { return QUrlTwoFlags(QFlag(i | f.i)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator|(E1 f) const
- { return QUrlTwoFlags(E1(i | f)); }
+ { return QUrlTwoFlags(QFlag(i | f)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator|(E2 f) const
- { return QUrlTwoFlags(E2(i | f)); }
+ { return QUrlTwoFlags(QFlag(i | f)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator^(QUrlTwoFlags f) const
- { return QUrlTwoFlags(E1(i ^ f.i)); }
+ { return QUrlTwoFlags(QFlag(i ^ f.i)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator^(E1 f) const
- { return QUrlTwoFlags(E1(i ^ f)); }
+ { return QUrlTwoFlags(QFlag(i ^ f)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator^(E2 f) const
- { return QUrlTwoFlags(E2(i ^ f)); }
+ { return QUrlTwoFlags(QFlag(i ^ f)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator&(int mask) const
- { return QUrlTwoFlags(E1(i & mask)); }
+ { return QUrlTwoFlags(QFlag(i & mask)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator&(uint mask) const
- { return QUrlTwoFlags(E1(i & mask)); }
+ { return QUrlTwoFlags(QFlag(i & mask)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator&(E1 f) const
- { return QUrlTwoFlags(E1(i & f)); }
+ { return QUrlTwoFlags(QFlag(i & f)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator&(E2 f) const
- { return QUrlTwoFlags(E2(i & f)); }
+ { return QUrlTwoFlags(QFlag(i & f)); }
Q_DECL_CONSTEXPR inline QUrlTwoFlags operator~() const
- { return QUrlTwoFlags(E1(~i)); }
+ { return QUrlTwoFlags(QFlag(~i)); }
inline bool testFlag(E1 f) const { return (i & f) == f && (f != 0 || i == int(f)); }
inline bool testFlag(E2 f) const { return (i & f) == f && (f != 0 || i == int(f)); }