From 85f6bd834e11bb6e9fcb5eedeb6bfb62dd50f7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 2 Sep 2025 14:10:18 +0200 Subject: [PATCH] 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 4f7b57ffd6cb21dc34f982b741ff9b8655562b0f. C4312 is however for "conversion of A to B of greater size", and in 4435877cf1cf91445c149c55aa22c94b9170788e 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. --- doc/snippets/Math.cpp | 19 ++++++++++++++----- doc/snippets/SceneGraph.cpp | 5 +++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/doc/snippets/Math.cpp b/doc/snippets/Math.cpp index cc226d04b..f82505f76 100644 --- a/doc/snippets/Math.cpp +++ b/doc/snippets/Math.cpp @@ -715,12 +715,19 @@ static_cast(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 } diff --git a/doc/snippets/SceneGraph.cpp b/doc/snippets/SceneGraph.cpp index 69a65cd82..a408a491c 100644 --- a/doc/snippets/SceneGraph.cpp +++ b/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 }