Browse Source

Work around last five remaining MSVC warnings.

pull/638/head
Vladimír Vondruš 2 years ago
parent
commit
4f7b57ffd6
  1. 20
      doc/snippets/Math.cpp
  2. 6
      src/Magnum/Array.h
  3. 10
      src/Magnum/SceneTools/Test/SceneConverterImplementationTest.cpp
  4. 5
      src/Magnum/ShaderTools/Implementation/spirv.h

20
doc/snippets/Math.cpp

@ -709,6 +709,13 @@ static_cast<void>(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<void>(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<Float>('\xFF');
@ -1223,6 +1240,9 @@ Float a = Math::unpack<Float>('\xFF');
// b = 1.0f
Float b = Math::unpack<Float, UnsignedByte>('\xFF');
/* [unpack-template-explicit] */
#ifdef CORRADE_TARGET_MSVC
#pragma warning(pop)
#endif
static_cast<void>(a);
static_cast<void>(b);
}

6
src/Magnum/Array.h

@ -91,8 +91,14 @@ template<UnsignedInt dimensions, class T> 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<class U, class V = typename std::enable_if<std::is_same<T, U>::value && dimensions != 1, T>::type>
constexpr /*implicit*/ Array(U value): Array(typename Containers::Implementation::GenerateSequence<dimensions>::Type{}, value) {}
#ifdef CORRADE_TARGET_MSVC
CORRADE_IGNORE_DEPRECATED_POP
#endif
#endif
/** @brief Convert to a vector */

10
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<void>(Trade::Implementation::printImageConverterInfo);
static_cast<void>(Trade::Implementation::printImporterInfo);
#ifdef CORRADE_TARGET_MSVC
#pragma warning(pop)
#endif
}
void SceneConverterImplementationTest::converterInfo() {

5
src/Magnum/ShaderTools/Implementation/spirv.h

@ -73,8 +73,9 @@ Containers::ArrayView<const UnsignedInt> 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);
}

Loading…
Cancel
Save