diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-31 18:27:41 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-06-04 00:22:56 +0000 |
commit | 8aacf83a76aa8d4896bbfb1b3a6e81fa697ae4e6 (patch) | |
tree | bb99219f6f3933babe2cf0a5aa540712675e81e1 | |
parent | d631e581c0853cd94310a9377458c117edcbd65d (diff) |
Make Q_ASSUME() an expression (was: statement)
Like Q_ASSERT(), which was fixed for 5.10, it's also useful if
Q_ASSUME() expands to an expression instead of a statement. This way,
it's usable in more contexts, esp. the comma operator.
[ChangeLog][QtCore][QtGlobal] Q_ASSUME() now expands to an expression
(was: statement).
Change-Id: I33dc3d1551a1b7454aa9587b9c33dfa2e3d2b09c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 2cbe9ee559..30d2a294dc 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1132,11 +1132,10 @@ } while (false) #define Q_ASSUME(Expr) \ - do {\ - const bool valueOfExpression = Expr;\ + [] (bool valueOfExpression) {\ Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\ Q_ASSUME_IMPL(valueOfExpression);\ - } while (false) + }(Expr) #if defined(__cplusplus) #if __has_cpp_attribute(clang::fallthrough) |