diff --git a/src/Magnum/DebugTools/CompareImage.cpp b/src/Magnum/DebugTools/CompareImage.cpp index 34f9b64c6..d5599737e 100644 --- a/src/Magnum/DebugTools/CompareImage.cpp +++ b/src/Magnum/DebugTools/CompareImage.cpp @@ -102,6 +102,10 @@ std::tuple, Float, Float> calculateImageDelta(const Pix CORRADE_ASSERT(!isPixelFormatImplementationSpecific(expected.format()), "DebugTools::CompareImage: can't compare implementation-specific pixel formats", {}); + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif Float max{Constants::nan()}; switch(expected.format()) { #define _c(format, size, T) \ @@ -157,6 +161,9 @@ std::tuple, Float, Float> calculateImageDelta(const Pix CORRADE_ASSERT(false, "DebugTools::CompareImage: half-float formats are not supported yet", {}); } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif CORRADE_ASSERT(max == max, "DebugTools::CompareImage: unknown format" << expected.format(), {}); @@ -225,6 +232,10 @@ namespace { void printPixelAt(Debug& out, const Containers::StridedArrayView3D& pixels, const Vector2i& pos, const PixelFormat format) { const char* const pixel = &pixels[pos.y()][pos.x()][0]; + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(format) { #define _c(format, size, T) \ case PixelFormat::format: \ @@ -284,6 +295,9 @@ void printPixelAt(Debug& out, const Containers::StridedArrayView3D& /* Already handled by a printing assert before */ CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif } } diff --git a/src/Magnum/GL/AbstractTexture.cpp b/src/Magnum/GL/AbstractTexture.cpp index f4398afaf..3c70c0bdb 100644 --- a/src/Magnum/GL/AbstractTexture.cpp +++ b/src/Magnum/GL/AbstractTexture.cpp @@ -539,6 +539,10 @@ void AbstractTexture::bindInternal() { namespace { PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) { + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(internalFormat) { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::Red: @@ -806,11 +810,18 @@ PixelFormat pixelFormatForInternalFormat(const TextureFormat internalFormat) { #endif return PixelFormat::DepthStencil; } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) { + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(internalFormat) { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case TextureFormat::Red: @@ -1053,6 +1064,9 @@ PixelType pixelTypeForInternalFormat(const TextureFormat internalFormat) { return PixelType::Float32UnsignedInt248Rev; #endif } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } diff --git a/src/Magnum/GL/PixelFormat.cpp b/src/Magnum/GL/PixelFormat.cpp index a0e37d1c2..ecd32933e 100644 --- a/src/Magnum/GL/PixelFormat.cpp +++ b/src/Magnum/GL/PixelFormat.cpp @@ -88,6 +88,10 @@ PixelType pixelType(const Magnum::PixelFormat format, const UnsignedInt extra) { UnsignedInt pixelSize(const PixelFormat format, const PixelType type) { std::size_t size = 0; + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(type) { case PixelType::UnsignedByte: #ifndef MAGNUM_TARGET_GLES2 @@ -144,7 +148,14 @@ UnsignedInt pixelSize(const PixelFormat format, const PixelType type) { return 8; #endif } - + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif + + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(format) { #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) case PixelFormat::Red: @@ -207,12 +218,19 @@ UnsignedInt pixelSize(const PixelFormat format, const PixelType type) { case PixelFormat::DepthStencil: CORRADE_ASSERT(false, "GL::pixelSize(): invalid" << type << "specified for" << format, 0); } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } #ifndef DOXYGEN_GENERATING_OUTPUT Debug& operator<<(Debug& debug, const PixelFormat value) { + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(value) { /* LCOV_EXCL_START */ #define _c(value) case PixelFormat::value: return debug << "GL::PixelFormat::" #value; @@ -266,11 +284,18 @@ Debug& operator<<(Debug& debug, const PixelFormat value) { #undef _c /* LCOV_EXCL_STOP */ } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif return debug << "GL::PixelFormat(" << Debug::nospace << reinterpret_cast(GLenum(value)) << Debug::nospace << ")"; } Debug& operator<<(Debug& debug, const PixelType value) { + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(value) { /* LCOV_EXCL_START */ #define _c(value) case PixelType::value: return debug << "GL::PixelType::" #value; @@ -323,6 +348,9 @@ Debug& operator<<(Debug& debug, const PixelType value) { #undef _c /* LCOV_EXCL_STOP */ } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif return debug << "GL::PixelType(" << Debug::nospace << reinterpret_cast(GLenum(value)) << Debug::nospace << ")"; } @@ -363,6 +391,10 @@ CompressedPixelFormat compressedPixelFormat(const Magnum::CompressedPixelFormat } Debug& operator<<(Debug& debug, const CompressedPixelFormat value) { + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(value) { /* LCOV_EXCL_START */ #define _c(value) case CompressedPixelFormat::value: return debug << "GL::CompressedPixelFormat::" #value; @@ -429,6 +461,9 @@ Debug& operator<<(Debug& debug, const CompressedPixelFormat value) { #undef _c /* LCOV_EXCL_STOP */ } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif return debug << "GL::CompressedPixelFormat(" << Debug::nospace << reinterpret_cast(GLenum(value)) << Debug::nospace << ")"; } diff --git a/src/Magnum/GL/Test/PixelFormatTest.cpp b/src/Magnum/GL/Test/PixelFormatTest.cpp index 7ff562e5e..77787f0d8 100644 --- a/src/Magnum/GL/Test/PixelFormatTest.cpp +++ b/src/Magnum/GL/Test/PixelFormatTest.cpp @@ -99,6 +99,10 @@ void PixelFormatTest::mapFormatType() { - that there was no gap (unhandled value inside the range) - that a particular pixel format maps to a particular GL format - that a particular pixel type maps to a particular GL type */ + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(format) { #define _c(format, expectedFormat, expectedType) \ case Magnum::PixelFormat::format: \ @@ -122,6 +126,9 @@ void PixelFormatTest::mapFormatType() { #undef _s #undef _c } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif /* Not handled by any value, remember -- we might either be at the end of the enum range (which is okay) or some value might be unhandled @@ -234,6 +241,10 @@ void PixelFormatTest::mapCompressedFormat() { - that there was no gap (unhandled value inside the range) - that a particular pixel format maps to a particular GL format - that a particular pixel type maps to a particular GL type */ + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(format) { #define _c(format, expectedFormat) \ case Magnum::CompressedPixelFormat::format: \ @@ -255,6 +266,9 @@ void PixelFormatTest::mapCompressedFormat() { #undef _s #undef _c } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif /* Not handled by any value, remember -- we might either be at the end of the enum range (which is okay) or some value might be unhandled diff --git a/src/Magnum/PixelFormat.cpp b/src/Magnum/PixelFormat.cpp index 9c354b99e..f117f4f11 100644 --- a/src/Magnum/PixelFormat.cpp +++ b/src/Magnum/PixelFormat.cpp @@ -34,6 +34,10 @@ UnsignedInt pixelSize(const PixelFormat format) { CORRADE_ASSERT(!(UnsignedInt(format) & (1 << 31)), "pixelSize(): can't determine pixel size of an implementation-specific format", {}); + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(format) { case PixelFormat::R8Unorm: case PixelFormat::R8Snorm: @@ -92,6 +96,9 @@ UnsignedInt pixelSize(const PixelFormat format) { case PixelFormat::RGBA32F: return 16; } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } @@ -102,6 +109,10 @@ Debug& operator<<(Debug& debug, const PixelFormat value) { return debug << "PixelFormat::ImplementationSpecific(" << Debug::nospace << reinterpret_cast(pixelFormatUnwrap(value)) << Debug::nospace << ")"; } + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(value) { /* LCOV_EXCL_START */ #define _c(value) case PixelFormat::value: return debug << "PixelFormat::" #value; @@ -156,6 +167,9 @@ Debug& operator<<(Debug& debug, const PixelFormat value) { #undef _c /* LCOV_EXCL_STOP */ } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif return debug << "PixelFormat(" << Debug::nospace << reinterpret_cast(UnsignedInt(value)) << Debug::nospace << ")"; } @@ -167,6 +181,10 @@ Debug& operator<<(Debug& debug, const CompressedPixelFormat value) { return debug << "CompressedPixelFormat::ImplementationSpecific(" << Debug::nospace << reinterpret_cast(compressedPixelFormatUnwrap(value)) << Debug::nospace << ")"; } + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(value) { /* LCOV_EXCL_START */ #define _c(value) case CompressedPixelFormat::value: return debug << "CompressedPixelFormat::" #value; @@ -187,6 +205,9 @@ Debug& operator<<(Debug& debug, const CompressedPixelFormat value) { #undef _c /* LCOV_EXCL_STOP */ } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif return debug << "CompressedPixelFormat(" << Debug::nospace << reinterpret_cast(UnsignedInt(value)) << Debug::nospace << ")"; } diff --git a/src/Magnum/Vk/Test/EnumsTest.cpp b/src/Magnum/Vk/Test/EnumsTest.cpp index efba298be..157059bc0 100644 --- a/src/Magnum/Vk/Test/EnumsTest.cpp +++ b/src/Magnum/Vk/Test/EnumsTest.cpp @@ -190,6 +190,10 @@ void EnumsTest::mapVkFormat() { - that there was no gap (unhandled value inside the range) - that a particular pixel format maps to a particular GL format - that a particular pixel type maps to a particular GL type */ + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(format) { #define _c(format, expectedFormat) \ case Magnum::PixelFormat::format: \ @@ -211,6 +215,9 @@ void EnumsTest::mapVkFormat() { #undef _s #undef _c } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif /* Not handled by any value, remember -- we might either be at the end of the enum range (which is okay) or some value might be unhandled @@ -267,6 +274,10 @@ void EnumsTest::mapVkFormatCompressed() { - that there was no gap (unhandled value inside the range) - that a particular pixel format maps to a particular GL format - that a particular pixel type maps to a particular GL type */ + #ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic error "-Wswitch" + #endif switch(format) { #define _c(format, expectedFormat) \ case Magnum::CompressedPixelFormat::format: \ @@ -288,6 +299,9 @@ void EnumsTest::mapVkFormatCompressed() { #undef _s #undef _c } + #ifdef __GNUC__ + #pragma GCC diagnostic pop + #endif /* Not handled by any value, remember -- we might either be at the end of the enum range (which is okay) or some value might be unhandled