Browse Source

doc: expand MSVC-/GCC-specific warning supporessions to clang-cl.

Strangely enough, that C4312 warning suppression now needs to be C4834
instead while I'm pretty sure it was correct back in March 2024 when I
added this in 4f7b57ffd6. C4312 is however
for "conversion of A to B of greater size", and in
4435877cf1 I was fixing a lot of those, so
maybe I just used the same number by accident and because this
particular warning is extremely easy to miss, it was never correct in
the first place? Who knows.
pull/680/head
Vladimír Vondruš 8 months ago
parent
commit
85f6bd834e
  1. 19
      doc/snippets/Math.cpp
  2. 5
      doc/snippets/SceneGraph.cpp

19
doc/snippets/Math.cpp

@ -715,12 +715,19 @@ static_cast<void>(d);
Float sine(Rad angle);
Float a = 60.0f;
Deg b;
/* "warning C4312: discarding return value of function with [[nodiscard]]
/* "warning C4834: 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
snippets anymore?!
Same happens on clang-cl (which uses the MSVC STL), but because clang-cl
reports itself as MSVC and for it the MSVC-specific warning suppressions
don't work, check for clang-cl first and for MSVC second. */
#ifdef CORRADE_TARGET_CLANG_CL
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-result"
#elif defined(CORRADE_TARGET_MSVC)
#pragma warning(push)
#pragma warning(disable: 4312)
#pragma warning(disable: 4834)
#endif
/* [Deg-usage-explicit-conversion] */
//sine(a); // compilation error
@ -731,7 +738,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
#ifdef CORRADE_TARGET_CLANG_CL
#pragma GCC diagnostic pop
#elif defined(CORRADE_TARGET_MSVC)
#pragma warning(pop)
#endif
}

5
doc/snippets/SceneGraph.cpp

@ -261,7 +261,8 @@ class MyObject: MyFeature, public Object3D {
/* [feature-construction-order-crash] */
}
{
#ifdef CORRADE_TARGET_GCC
/* clang-cl doesn't report itself as GCC but warns too, check it explicitly */
#if defined(CORRADE_TARGET_GCC) || defined(CORRADE_TARGET_CLANG_CL)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreorder"
#endif
@ -274,7 +275,7 @@ class MyObject: MyFeature, public Object3D {
};
/* [feature-construction-order-crash-destruction] */
}
#ifdef CORRADE_TARGET_GCC
#if defined(CORRADE_TARGET_GCC) || defined(CORRADE_TARGET_CLANG_CL)
#pragma GCC diagnostic pop
#endif
}

Loading…
Cancel
Save