From 4f7b57ffd6cb21dc34f982b741ff9b8655562b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 5 Mar 2024 23:10:20 +0100 Subject: [PATCH] Work around last five remaining MSVC warnings. --- doc/snippets/Math.cpp | 20 +++++++++++++++++++ src/Magnum/Array.h | 6 ++++++ .../Test/SceneConverterImplementationTest.cpp | 10 +++++++++- src/Magnum/ShaderTools/Implementation/spirv.h | 5 +++-- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/doc/snippets/Math.cpp b/doc/snippets/Math.cpp index 5ff2f4430..62d955232 100644 --- a/doc/snippets/Math.cpp +++ b/doc/snippets/Math.cpp @@ -709,6 +709,13 @@ static_cast(d); Float sine(Rad angle); Float a = 60.0f; Deg b; +/* "warning C4312: discarding return value of function with [[nodiscard]] + attribute". Yeah, of course it is. Am I not allowed to write succint code + snippets anymore?! */ +#ifdef CORRADE_TARGET_MSVC +#pragma warning(push) +#pragma warning(disable: 4312) +#endif /* [Deg-usage-explicit-conversion] */ //sine(a); // compilation error sine(Deg{a}); // explicitly specifying unit @@ -718,6 +725,9 @@ std::sin(Float(Rad{b})); // required explicit conversion hints to user // that this case needs special attention // (i.e., conversion to radians) /* [Deg-usage-explicit-conversion] */ +#ifdef CORRADE_TARGET_MSVC +#pragma warning(pop) +#endif } { @@ -1216,6 +1226,13 @@ static_cast(axis); } { +/* The second expression gives "warning C4245: 'argument': conversion from + 'char' to 'const Magnum::UnsignedByte', signed/unsigned mismatch". Well, + yes. Shut up. */ +#ifdef CORRADE_TARGET_MSVC +#pragma warning(push) +#pragma warning(disable: 4245) +#endif /* [unpack-template-explicit] */ // Literal type is (signed) char, but we assumed unsigned char, a != 1.0f Float a = Math::unpack('\xFF'); @@ -1223,6 +1240,9 @@ Float a = Math::unpack('\xFF'); // b = 1.0f Float b = Math::unpack('\xFF'); /* [unpack-template-explicit] */ +#ifdef CORRADE_TARGET_MSVC +#pragma warning(pop) +#endif static_cast(a); static_cast(b); } diff --git a/src/Magnum/Array.h b/src/Magnum/Array.h index 3b1c2a8aa..12f17063d 100644 --- a/src/Magnum/Array.h +++ b/src/Magnum/Array.h @@ -91,8 +91,14 @@ template class CORRADE_DEPRECATED("use Math::Ve #ifdef DOXYGEN_GENERATING_OUTPUT constexpr /*implicit*/ Array(T value); #else + #ifdef CORRADE_TARGET_MSVC /* MSVC warns for the constructor delegation */ + CORRADE_IGNORE_DEPRECATED_PUSH + #endif template::value && dimensions != 1, T>::type> constexpr /*implicit*/ Array(U value): Array(typename Containers::Implementation::GenerateSequence::Type{}, value) {} + #ifdef CORRADE_TARGET_MSVC + CORRADE_IGNORE_DEPRECATED_POP + #endif #endif /** @brief Convert to a vector */ diff --git a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp index f2237341e..3f95e7c22 100644 --- a/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp +++ b/src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp @@ -176,9 +176,17 @@ SceneConverterImplementationTest::SceneConverterImplementationTest() { /* To avoid warnings that printImageConverterInfo() / printImporterInfo() is unused. Again, those are tested in ImageConverterImplementationTest - already. */ + already. MSVC says "warning C4551: function call missing argument list" + here. No shit, you stupid thing. */ + #ifdef CORRADE_TARGET_MSVC + #pragma warning(push) + #pragma warning(disable: 4551) + #endif static_cast(Trade::Implementation::printImageConverterInfo); static_cast(Trade::Implementation::printImporterInfo); + #ifdef CORRADE_TARGET_MSVC + #pragma warning(pop) + #endif } void SceneConverterImplementationTest::converterInfo() { diff --git a/src/Magnum/ShaderTools/Implementation/spirv.h b/src/Magnum/ShaderTools/Implementation/spirv.h index 3a3ec8498..929006a3a 100644 --- a/src/Magnum/ShaderTools/Implementation/spirv.h +++ b/src/Magnum/ShaderTools/Implementation/spirv.h @@ -73,8 +73,9 @@ Containers::ArrayView spirvFindInstruction(Containers::ArrayV } /* This is the instruction we're looking for, return it and update the - view to point after it. */ - if(instructionOp == op) { + view to point after it. SpvOp cast is needed to avoid a MSVC + "warning C4389: '==': signed/unsigned mismatch". */ + if(SpvOp(instructionOp) == op) { data = dataIteration.exceptPrefix(instructionSize); return dataIteration.prefix(instructionSize); }