47 lines
1.7 KiB
Diff
47 lines
1.7 KiB
Diff
|
|
From 4c052f763fbc799cebb08273a3bb9de3a03b1f27 Mon Sep 17 00:00:00 2001
|
||
|
|
From: lizhenhua <lizhenhua@sina.com>
|
||
|
|
Date: Fri, 22 May 2020 15:58:42 +0800
|
||
|
|
Subject: [PATCH] Redo the Q_FOREACH loop control without GCC statement
|
||
|
|
expressions
|
||
|
|
|
||
|
|
---
|
||
|
|
src/corelib/global/qglobal.h | 12 ++++++------
|
||
|
|
1 file changed, 6 insertions(+), 6 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
|
||
|
|
index 3c3bc32a..48f105b1 100644
|
||
|
|
--- a/src/corelib/global/qglobal.h
|
||
|
|
+++ b/src/corelib/global/qglobal.h
|
||
|
|
@@ -2482,22 +2482,22 @@ typedef uint Flags;
|
||
|
|
|
||
|
|
#endif /* Q_NO_TYPESAFE_FLAGS */
|
||
|
|
|
||
|
|
-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
|
||
|
|
+#if (defined(Q_CC_GNU) && !defined(Q_CC_RVCT))
|
||
|
|
/* make use of typeof-extension */
|
||
|
|
template <typename T>
|
||
|
|
class QForeachContainer {
|
||
|
|
public:
|
||
|
|
- inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { }
|
||
|
|
+ inline QForeachContainer(const T& t) : c(t), i(c.begin()), e(c.end()), control(1) { }
|
||
|
|
const T c;
|
||
|
|
- int brk;
|
||
|
|
typename T::const_iterator i, e;
|
||
|
|
+ int control;
|
||
|
|
};
|
||
|
|
|
||
|
|
#define Q_FOREACH(variable, container) \
|
||
|
|
for (QForeachContainer<__typeof__(container)> _container_(container); \
|
||
|
|
- !_container_.brk && _container_.i != _container_.e; \
|
||
|
|
- __extension__ ({ ++_container_.brk; ++_container_.i; })) \
|
||
|
|
- for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))
|
||
|
|
+ _container_.control && _container_.i != _container_.e; \
|
||
|
|
+ ++_container_.i, _container_.control ^= 1) \
|
||
|
|
+ for (variable = *_container_.i; _container_.control; _container_.control = 0)
|
||
|
|
|
||
|
|
#else
|
||
|
|
|
||
|
|
--
|
||
|
|
2.23.0
|
||
|
|
|