MSVC: Enable all possible conformance checks

For the full list, please refer to [1].

Needed to change the qstringapisymmetry unit test:
In theory we don't need the array to be static and it did compile
without any problems so far, indeed. However, with this patch applied,
MSVC complains that the lambda function below can't access the array.
I don't understand why, because we use [&] in the lambda and it should
capture all the variables in theory, but in reality it failed to
capture this variable in the end. And making the variable static
solves this issue. Maybe it's a MSVC bug.

Already tested locally. Most Qt repos build without any issues,
only very few repos are not tested, as my local environment
can't build them.

[1] https://docs.microsoft.com/en-us/cpp/build/reference/zc-conformance?view=msvc-170

Change-Id: I658427aa171ee1ae26610d0c68640b2f50789f15
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Yuhang Zhao 2022-08-25 10:36:48 +08:00 committed by Marc Mutz
parent 0a4d0ac013
commit 8cb832090a
2 changed files with 6 additions and 3 deletions

View File

@ -239,14 +239,17 @@ if (MSVC)
)
endif()
endif()
if (MSVC_VERSION GREATER_EQUAL 1909 AND NOT CLANG)
if (MSVC_VERSION GREATER_EQUAL 1909 AND NOT CLANG) # MSVC 2017
target_compile_options(PlatformCommonInternal INTERFACE
-Zc:referenceBinding
-Zc:ternary
)
endif()
if (MSVC_VERSION GREATER_EQUAL 1919 AND NOT CLANG)
if (MSVC_VERSION GREATER_EQUAL 1919 AND NOT CLANG) # MSVC 2019
target_compile_options(PlatformCommonInternal INTERFACE
-Zc:externConstexpr
-Zc:lambda
-Zc:preprocessor
)
endif()

View File

@ -2625,7 +2625,7 @@ void tst_QStringApiSymmetry::toNumberWithBases_data()
QTest::addColumn<qint64>("result");
QTest::addColumn<bool>("ok");
constexpr struct {
static constexpr struct {
const char prefix[3];
int base;
} bases[] = {