From ab55f9f39b8c7716500d74dd32ae813df76623c4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 22 Sep 2013 05:17:22 +0200 Subject: Q_STATIC_ASSERT: use __COUNTER__ instead of __LINE__ if the compiler supports it When using __LINE__ to construct unique names, use of Q_STATIC_ASSERT is limited to one instance per line of code. On compilers that support __COUNTER__ (GCC and MSVC, probably others), we can get around that limitation by using that one to always get a new unique number, so use it. Change-Id: I89bcfaa32376b7a665f03e4275e89b13fa3e650d Reviewed-by: Thiago Macieira --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 3696ee264f..290afec776 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -290,6 +290,11 @@ void tst_QGlobal::qstaticassert() Q_UNUSED(tmp1); Q_UNUSED(tmp2); Q_UNUSED(tmp3); +#ifdef __COUNTER__ + // if the compiler supports __COUNTER__, multiple + // Q_STATIC_ASSERT's on a single line should compile: + Q_STATIC_ASSERT(true); Q_STATIC_ASSERT_X(!false, ""); +#endif // __COUNTER__ QVERIFY(true); // if the test compiles it has passed. } -- cgit v1.2.3