From c7cb6bd3b5de63f1fb5d39025edce560dba41b2b Mon Sep 17 00:00:00 2001 From: Christophe Date: Tue, 9 Jan 2024 15:01:33 +0100 Subject: [PATCH] Disable warnings by default --- glm/detail/setup.hpp | 6 ++-- glm/detail/type_quat.hpp | 40 +++++++++++------------ glm/ext/scalar_ulp.inl | 6 ++++ glm/gtc/packing.inl | 13 ++++++++ test/bug/bug_ms_vec_static.cpp | 9 +++++ test/core/core_force_compiler_unknown.cpp | 22 +++++++++++++ test/core/core_func_integer_bit_count.cpp | 9 +++++ test/core/core_func_integer_find_lsb.cpp | 10 ++++++ test/core/core_func_integer_find_msb.cpp | 10 ++++++ test/gtc/gtc_integer.cpp | 27 +++++++++++++++ 10 files changed, 129 insertions(+), 23 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 19953bcb4e..efc4ed6589 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -877,10 +877,10 @@ namespace detail /////////////////////////////////////////////////////////////////////////////////// // Silent warnings -#ifdef GLM_FORCE_SILENT_WARNINGS -# define GLM_SILENT_WARNINGS GLM_ENABLE -#else +#ifdef GLM_FORCE_WARNINGS # define GLM_SILENT_WARNINGS GLM_DISABLE +#else +# define GLM_SILENT_WARNINGS GLM_ENABLE #endif /////////////////////////////////////////////////////////////////////////////////// diff --git a/glm/detail/type_quat.hpp b/glm/detail/type_quat.hpp index d489e0a233..586785a7e2 100644 --- a/glm/detail/type_quat.hpp +++ b/glm/detail/type_quat.hpp @@ -15,16 +15,6 @@ namespace glm { - template - struct qua - { - // -- Implementation detail -- - - typedef qua type; - typedef T value_type; - - // -- Data -- - # if GLM_SILENT_WARNINGS == GLM_ENABLE # if GLM_COMPILER & GLM_COMPILER_GCC # pragma GCC diagnostic push @@ -39,6 +29,16 @@ namespace glm # endif # endif + template + struct qua + { + // -- Implementation detail -- + + typedef qua type; + typedef T value_type; + + // -- Data -- + # if GLM_LANG & GLM_LANG_CXXMS_FLAG union { @@ -56,16 +56,6 @@ namespace glm # else T x, y, z, w; # endif -# endif - -# if GLM_SILENT_WARNINGS == GLM_ENABLE -# if GLM_COMPILER & GLM_COMPILER_CLANG -# pragma clang diagnostic pop -# elif GLM_COMPILER & GLM_COMPILER_GCC -# pragma GCC diagnostic pop -# elif GLM_COMPILER & GLM_COMPILER_VC -# pragma warning(pop) -# endif # endif // -- Component accesses -- @@ -139,6 +129,16 @@ namespace glm GLM_FUNC_DECL GLM_CONSTEXPR qua& operator/=(U s); }; +# if GLM_SILENT_WARNINGS == GLM_ENABLE +# if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +# elif GLM_COMPILER & GLM_COMPILER_GCC +# pragma GCC diagnostic pop +# elif GLM_COMPILER & GLM_COMPILER_VC +# pragma warning(pop) +# endif +# endif + // -- Unary bit operators -- template diff --git a/glm/ext/scalar_ulp.inl b/glm/ext/scalar_ulp.inl index 89f347e441..70214c3ad5 100644 --- a/glm/ext/scalar_ulp.inl +++ b/glm/ext/scalar_ulp.inl @@ -13,6 +13,10 @@ #if(GLM_COMPILER & GLM_COMPILER_VC) # pragma warning(push) # pragma warning(disable : 4127) +#elif GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wsign-conversion" +# pragma clang diagnostic ignored "-Wpadded" #endif typedef union @@ -184,6 +188,8 @@ namespace detail #if(GLM_COMPILER & GLM_COMPILER_VC) # pragma warning(pop) +#elif GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop #endif namespace glm diff --git a/glm/gtc/packing.inl b/glm/gtc/packing.inl index 3f0c63a7b5..c979f30abc 100644 --- a/glm/gtc/packing.inl +++ b/glm/gtc/packing.inl @@ -179,6 +179,13 @@ namespace detail // return ((floatTo11bit(x) & ((1 << 11) - 1)) << 0) | ((floatTo11bit(y) & ((1 << 11) - 1)) << 11) | ((floatTo10bit(z) & ((1 << 10) - 1)) << 22); // } +#if GLM_SILENT_WARNINGS == GLM_ENABLE +# if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +# endif +#endif + union u3u3u2 { struct Data @@ -235,6 +242,12 @@ namespace detail uint16 pack; }; +#if GLM_SILENT_WARNINGS == GLM_ENABLE +# if defined(__clang__) +# pragma clang diagnostic pop +# endif +#endif + union u10u10u10u2 { struct Data diff --git a/test/bug/bug_ms_vec_static.cpp b/test/bug/bug_ms_vec_static.cpp index 7f44e409a7..ed62212899 100644 --- a/test/bug/bug_ms_vec_static.cpp +++ b/test/bug/bug_ms_vec_static.cpp @@ -14,11 +14,20 @@ struct vec2 x(0), y(0) {} +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union +#endif + union { struct { float x, y; }; struct { _swizzle xx; }; }; + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif }; #endif diff --git a/test/core/core_force_compiler_unknown.cpp b/test/core/core_force_compiler_unknown.cpp index 44d7fc3365..439d8f8b68 100644 --- a/test/core/core_force_compiler_unknown.cpp +++ b/test/core/core_force_compiler_unknown.cpp @@ -2,9 +2,31 @@ # define GLM_FORCE_COMPILER_UNKNOWN #endif +# if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpedantic" +# elif defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wgnu-anonymous-struct" +# pragma clang diagnostic ignored "-Wnested-anon-types" +# pragma clang diagnostic ignored "-Wsign-conversion" +# pragma clang diagnostic ignored "-Wpadded" +# elif defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4201) // nonstandard extension used : nameless struct/union +# endif + #include #include +# if defined(__clang__) +# pragma clang diagnostic pop +# elif defined(__GNUC__) +# pragma GCC diagnostic pop +# elif defined(_MSC_VER) +# pragma warning(pop) +# endif + int main() { int Error = 0; diff --git a/test/core/core_func_integer_bit_count.cpp b/test/core/core_func_integer_bit_count.cpp index 0fa11fbe3f..829f182f36 100644 --- a/test/core/core_func_integer_bit_count.cpp +++ b/test/core/core_func_integer_bit_count.cpp @@ -174,6 +174,11 @@ void error(int x, int y) std::printf("Error for x = %08x, got %08x\n", x, y); } +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4389) // nonstandard extension used : nameless struct/union +#endif + int main() { # ifdef NDEBUG @@ -289,3 +294,7 @@ int main() # endif//NDEBUG } + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif diff --git a/test/core/core_func_integer_find_lsb.cpp b/test/core/core_func_integer_find_lsb.cpp index 0a3312f29c..4ef45d1c5d 100644 --- a/test/core/core_func_integer_find_lsb.cpp +++ b/test/core/core_func_integer_find_lsb.cpp @@ -285,6 +285,11 @@ void error(int x, int y) { std::printf("Error for x = %08x, got %d\n", x, y); } +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4389) // nonstandard extension used : nameless struct/union +#endif + int main() { # ifdef NDEBUG @@ -429,3 +434,8 @@ int main() # endif//NDEBUG } + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + diff --git a/test/core/core_func_integer_find_msb.cpp b/test/core/core_func_integer_find_msb.cpp index 61bee61f09..e7b3c30213 100644 --- a/test/core/core_func_integer_find_msb.cpp +++ b/test/core/core_func_integer_find_msb.cpp @@ -310,6 +310,11 @@ void error(int x, int y) std::printf("Error for x = %08x, got %d\n", x, y); } +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4389) // nonstandard extension used : nameless struct/union +#endif + int main() { # ifdef NDEBUG @@ -447,3 +452,8 @@ int main() # endif//NDEBUG } + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + diff --git a/test/gtc/gtc_integer.cpp b/test/gtc/gtc_integer.cpp index 769d969033..07b59adbe1 100644 --- a/test/gtc/gtc_integer.cpp +++ b/test/gtc/gtc_integer.cpp @@ -92,6 +92,11 @@ namespace log2_ std::clock_t Begin = clock(); +#if GLM_COMPILER& GLM_COMPILER_VC +# pragma warning(push) +# pragma warning(disable: 4267) +#endif + for(std::size_t i = 0; i < Count; ++i) { glm::vec<4, unsigned long, glm::defaultp> Tmp; @@ -102,6 +107,10 @@ namespace log2_ Result[i] = glm::ivec4(Tmp); } +#if GLM_COMPILER & GLM_COMPILER_VC +# pragma warning(pop) +#endif + std::clock_t End = clock(); std::printf("glm::log2 inlined: %d clocks\n", static_cast(End - Begin)); @@ -114,6 +123,11 @@ namespace log2_ std::clock_t Begin = clock(); +#if GLM_COMPILER& GLM_COMPILER_VC +# pragma warning(push) +# pragma warning(disable: 4267) +#endif + for(std::size_t i = 0; i < Count; ++i) { _BitScanReverse(&Result[i].x, i); @@ -122,6 +136,10 @@ namespace log2_ _BitScanReverse(&Result[i].w, i); } +#if GLM_COMPILER & GLM_COMPILER_VC +# pragma warning(pop) +#endif + std::clock_t End = clock(); std::printf("glm::log2 inlined no cast: %d clocks\n", static_cast(End - Begin)); @@ -134,6 +152,11 @@ namespace log2_ std::clock_t Begin = clock(); +#if GLM_COMPILER& GLM_COMPILER_VC +# pragma warning(push) +# pragma warning(disable: 4267) +#endif + for(std::size_t i = 0; i < Count; ++i) { _BitScanReverse(reinterpret_cast(&Result[i].x), i); @@ -142,6 +165,10 @@ namespace log2_ _BitScanReverse(reinterpret_cast(&Result[i].w), i); } +#if GLM_COMPILER & GLM_COMPILER_VC +# pragma warning(pop) +#endif + std::clock_t End = clock(); std::printf("glm::log2 reinterpret: %d clocks\n", static_cast(End - Begin));