From 6025c36d014d77091d09271d68154261d1977761 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 9 Mar 2015 20:48:05 -0700 Subject: [PATCH] Make Q_ASSERT_X also check its argument for validity Commit ebef2ad1360c80ad62de5f4a1c4e7e4051725c1c did it for Q_ASSERT, but I somehow forgot to do it for Q_ASSERT_X. Do it now. This includes the fix from 9a3d7adaad367417aaa2e1ee1f996185a881a4b5 to silence a Clang warning. Change-Id: Iee8cbc07c4434ce9b560ffff13ca066a5b5ab5d4 Reviewed-by: Oswald Buddenhagen Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qcompilerdetection.h | 1 - src/corelib/global/qglobal.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 0ca67df1e28..1774378c065 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1164,7 +1164,6 @@ const bool valueOfExpression = Expr;\ Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\ Q_ASSUME_IMPL(valueOfExpression);\ - Q_UNUSED(valueOfExpression); /* the value may not be used if Q_ASSERT_X and Q_ASSUME_IMPL are noop */\ } while (0) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index ddba460b066..27a3bf7c3db 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -681,7 +681,7 @@ Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char * #if !defined(Q_ASSERT_X) # if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) -# define Q_ASSERT_X(cond, where, what) qt_noop() +# define Q_ASSERT_X(cond, where, what) do { } while ((false) && (cond)) # else # define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop()) # endif