From bc7d93b469522120f55b25d9a261af155d96e379 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 | 10 ++++- glm/gtc/packing.inl | 13 +++++++ test/bug/bug_ms_vec_static.cpp | 9 +++++ test/core/core_force_compiler_unknown.cpp | 23 +++++++++++ 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/core/core_type_cast.cpp | 32 +++++++++------ test/core/core_type_mat2x2.cpp | 34 +++++++++++----- test/core/core_type_mat2x3.cpp | 30 +++++++++++---- test/core/core_type_mat2x4.cpp | 26 ++++++++++--- test/core/core_type_mat3x2.cpp | 28 +++++++++++--- test/core/core_type_mat3x3.cpp | 24 ++++++++++-- test/core/core_type_mat3x4.cpp | 28 +++++++++++--- test/core/core_type_mat4x2.cpp | 26 ++++++++++--- test/core/core_type_mat4x3.cpp | 26 ++++++++++--- test/core/core_type_vec1.cpp | 47 ++++++++++++++++------- test/core/core_type_vec2.cpp | 20 ++++++++++ test/core/core_type_vec3.cpp | 23 +++++++---- test/core/core_type_vec4.cpp | 9 +++++ test/gtc/gtc_integer.cpp | 27 +++++++++++++ 23 files changed, 405 insertions(+), 105 deletions(-) diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 19953bcb4..efc4ed658 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 d489e0a23..586785a7e 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 89f347e44..9858dc058 100644 --- a/glm/ext/scalar_ulp.inl +++ b/glm/ext/scalar_ulp.inl @@ -10,9 +10,13 @@ #include #include -#if(GLM_COMPILER & GLM_COMPILER_VC) +#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 @@ -182,8 +186,10 @@ namespace detail }//namespace detail }//namespace glm -#if(GLM_COMPILER & GLM_COMPILER_VC) +#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 3f0c63a7b..c979f30ab 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 7f44e409a..ed6221289 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 44d7fc336..33284d09b 100644 --- a/test/core/core_force_compiler_unknown.cpp +++ b/test/core/core_force_compiler_unknown.cpp @@ -2,9 +2,32 @@ # define GLM_FORCE_COMPILER_UNKNOWN #endif +#if 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" +# pragma clang diagnostic ignored "-Wc++11-long-long" +#elif defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wpedantic" +#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 0fa11fbe3..829f182f3 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 0a3312f29..4ef45d1c5 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 61bee61f0..e7b3c3021 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/core/core_type_cast.cpp b/test/core/core_type_cast.cpp index 7ff1901e1..0f136ac43 100644 --- a/test/core/core_type_cast.cpp +++ b/test/core/core_type_cast.cpp @@ -11,33 +11,41 @@ struct my_vec2 float x, y; }; -int test_vec2_cast() +static int test_vec2_cast() { + int Error(0); + glm::vec2 A(1.0f, 2.0f); glm::lowp_vec2 B(A); glm::mediump_vec2 C(A); glm::highp_vec2 D(A); - + glm::vec2 E = static_cast(A); glm::lowp_vec2 F = static_cast(A); glm::mediump_vec2 G = static_cast(A); glm::highp_vec2 H = static_cast(A); - - my_vec2 I; - glm::vec2 J = static_cast(I); - glm::vec2 K(7.8f); - int Error(0); - Error += glm::all(glm::equal(A, E, glm::epsilon())) ? 0 : 1; Error += glm::all(glm::equal(B, F, glm::epsilon())) ? 0 : 1; Error += glm::all(glm::equal(C, G, glm::epsilon())) ? 0 : 1; Error += glm::all(glm::equal(D, H, glm::epsilon())) ? 0 : 1; - + + my_vec2 I; + I.x = 1.0f; + I.y = 2.0f; + glm::vec2 J0 = static_cast(I); + glm::vec2 J1(1.0f, 2.0f); + + Error += glm::all(glm::equal(J1, J0, glm::epsilon())) ? 0 : 1; + + glm::vec2 K(7.8f); + glm::vec2 L(7.8f, 7.8f); + Error += glm::all(glm::equal(K, L, glm::epsilon())) ? 0 : 1; + return Error; } -int test_vec3_cast() +static int test_vec3_cast() { glm::vec3 A(1.0f, 2.0f, 3.0f); glm::lowp_vec3 B(A); @@ -59,7 +67,7 @@ int test_vec3_cast() return Error; } -int test_vec4_cast() +static int test_vec4_cast() { glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); glm::lowp_vec4 B(A); @@ -81,7 +89,7 @@ int test_vec4_cast() return Error; } -int test_std_copy() +static int test_std_copy() { int Error = 0; diff --git a/test/core/core_type_mat2x2.cpp b/test/core/core_type_mat2x2.cpp index 2f8b018f6..ac1d876b4 100644 --- a/test/core/core_type_mat2x2.cpp +++ b/test/core/core_type_mat2x2.cpp @@ -15,26 +15,42 @@ #include #include -int test_operators() +static int test_operators() { + int Error = 0; + glm::mat2x2 l(1.0f); glm::mat2x2 m(1.0f); glm::vec2 u(1.0f); glm::vec2 v(1.0f); float x = 1.0f; + glm::vec2 a = m * u; + Error += glm::all(glm::equal(a, glm::vec2(1.0f), glm::epsilon())) ? 0 : 1; + glm::vec2 b = v * m; - glm::mat2x2 n = x / m; + Error += glm::all(glm::equal(b, glm::vec2(1.0f), glm::epsilon())) ? 0 : 1; + + glm::mat2x2 n0(1.0f, 1.0f, 1.0f, 1.0f); + glm::mat2x2 n = x / n0; + Error += glm::all(glm::equal(n, n0, glm::epsilon())) ? 0 : 1; + glm::mat2x2 o = m / x; + Error += glm::all(glm::equal(o, m, glm::epsilon())) ? 0 : 1; + glm::mat2x2 p = x * m; + Error += glm::all(glm::equal(p, m, glm::epsilon())) ? 0 : 1; + glm::mat2x2 q = m * x; bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); bool S = glm::all(glm::equal(m, l, glm::epsilon())); - return (S && !R) ? 0 : 1; + Error += (S && !R) ? 0 : 1; + + return Error; } -int test_inverse() +static int test_inverse() { int Error(0); @@ -58,7 +74,7 @@ int test_inverse() return Error; } -int test_ctr() +static int test_ctr() { int Error = 0; @@ -108,7 +124,7 @@ int test_ctr() namespace cast { template - int entry() + static int entry() { int Error = 0; @@ -121,7 +137,7 @@ namespace cast return Error; } - int test() + static int test() { int Error = 0; @@ -139,7 +155,7 @@ namespace cast } }//namespace cast -int test_size() +static int test_size() { int Error = 0; @@ -153,7 +169,7 @@ int test_size() return Error; } -int test_constexpr() +static int test_constexpr() { #if GLM_HAS_CONSTEXPR static_assert(glm::mat2x2::length() == 2, "GLM: Failed constexpr"); diff --git a/test/core/core_type_mat2x3.cpp b/test/core/core_type_mat2x3.cpp index e3ad76bbc..0e9737df3 100644 --- a/test/core/core_type_mat2x3.cpp +++ b/test/core/core_type_mat2x3.cpp @@ -15,24 +15,40 @@ static int test_operators() { + int Error = 0; + glm::mat2x3 l(1.0f); glm::mat2x3 m(1.0f); glm::vec2 u(1.0f); glm::vec3 v(1.0f); + float x = 1.0f; glm::vec3 a = m * u; + Error += glm::all(glm::equal(a, glm::vec3(u, 0.0f), glm::epsilon())) ? 0 : 1; + glm::vec2 b = v * m; - glm::mat2x3 n = x / m; + Error += glm::all(glm::equal(b, glm::vec2(1.0f), glm::epsilon())) ? 0 : 1; + + glm::mat2x3 n0(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); + glm::mat2x3 n = x / n0; + Error += glm::all(glm::equal(n, n0, glm::epsilon())) ? 0 : 1; + glm::mat2x3 o = m / x; + Error += glm::all(glm::equal(o, m, glm::epsilon())) ? 0 : 1; + glm::mat2x3 p = x * m; + Error += glm::all(glm::equal(p, m, glm::epsilon())) ? 0 : 1; + glm::mat2x3 q = m * x; bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); bool S = glm::all(glm::equal(m, l, glm::epsilon())); - return (S && !R) ? 0 : 1; + Error += (S && !R) ? 0 : 1; + + return Error; } -int test_ctr() +static int test_ctr() { int Error(0); @@ -74,7 +90,7 @@ int test_ctr() namespace cast { template - int entry() + static int entry() { int Error = 0; @@ -87,7 +103,7 @@ namespace cast return Error; } - int test() + static int test() { int Error = 0; @@ -105,7 +121,7 @@ namespace cast } }//namespace cast -int test_size() +static int test_size() { int Error = 0; @@ -119,7 +135,7 @@ int test_size() return Error; } -int test_constexpr() +static int test_constexpr() { #if GLM_HAS_CONSTEXPR static_assert(glm::mat2x3::length() == 2, "GLM: Failed constexpr"); diff --git a/test/core/core_type_mat2x4.cpp b/test/core/core_type_mat2x4.cpp index ade3a4444..623f03daa 100644 --- a/test/core/core_type_mat2x4.cpp +++ b/test/core/core_type_mat2x4.cpp @@ -16,24 +16,40 @@ static int test_operators() { + int Error = 0; + glm::mat2x4 l(1.0f); glm::mat2x4 m(1.0f); glm::vec2 u(1.0f); glm::vec4 v(1.0f); + float x = 1.0f; glm::vec4 a = m * u; + Error += glm::all(glm::equal(a, glm::vec4(u, 0.0f, 0.0f), glm::epsilon())) ? 0 : 1; + glm::vec2 b = v * m; - glm::mat2x4 n = x / m; + Error += glm::all(glm::equal(b, glm::vec2(1.0f), glm::epsilon())) ? 0 : 1; + + glm::mat2x4 n0(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); + glm::mat2x4 n = x / n0; + Error += glm::all(glm::equal(n, n0, glm::epsilon())) ? 0 : 1; + glm::mat2x4 o = m / x; + Error += glm::all(glm::equal(o, m, glm::epsilon())) ? 0 : 1; + glm::mat2x4 p = x * m; + Error += glm::all(glm::equal(p, m, glm::epsilon())) ? 0 : 1; + glm::mat2x4 q = m * x; bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); bool S = glm::all(glm::equal(m, l, glm::epsilon())); - return (S && !R) ? 0 : 1; + Error += (S && !R) ? 0 : 1; + + return Error; } -int test_ctr() +static int test_ctr() { int Error(0); @@ -75,7 +91,7 @@ int test_ctr() namespace cast { template - int entry() + static int entry() { int Error = 0; @@ -89,7 +105,7 @@ namespace cast return Error; } - int test() + static int test() { int Error = 0; diff --git a/test/core/core_type_mat3x2.cpp b/test/core/core_type_mat3x2.cpp index 7a40f90f8..a11a4b217 100644 --- a/test/core/core_type_mat3x2.cpp +++ b/test/core/core_type_mat3x2.cpp @@ -13,26 +13,42 @@ #include #include -static bool test_operators() +static int test_operators() { + int Error = 0; + glm::mat3x2 l(1.0f); glm::mat3x2 m(1.0f); glm::vec3 u(1.0f); glm::vec2 v(1.0f); + float x = 1.0f; glm::vec2 a = m * u; + Error += glm::all(glm::equal(a, glm::vec2(1.0f), glm::epsilon())) ? 0 : 1; + glm::vec3 b = v * m; - glm::mat3x2 n = x / m; + Error += glm::all(glm::equal(b, glm::vec3(v, 0.0f), glm::epsilon())) ? 0 : 1; + + glm::mat3x2 n0(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); + glm::mat3x2 n = x / n0; + Error += glm::all(glm::equal(n, n0, glm::epsilon())) ? 0 : 1; + glm::mat3x2 o = m / x; + Error += glm::all(glm::equal(o, m, glm::epsilon())) ? 0 : 1; + glm::mat3x2 p = x * m; + Error += glm::all(glm::equal(p, m, glm::epsilon())) ? 0 : 1; + glm::mat3x2 q = m * x; bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); bool S = glm::all(glm::equal(m, l, glm::epsilon())); - return (S && !R) ? 0 : 1; + Error += (S && !R) ? 0 : 1; + + return Error; } -int test_ctr() +static int test_ctr() { int Error(0); @@ -78,7 +94,7 @@ int test_ctr() namespace cast { template - int entry() + static int entry() { int Error = 0; @@ -91,7 +107,7 @@ namespace cast return Error; } - int test() + static int test() { int Error = 0; diff --git a/test/core/core_type_mat3x3.cpp b/test/core/core_type_mat3x3.cpp index 99e1f41e0..d79ffeedc 100644 --- a/test/core/core_type_mat3x3.cpp +++ b/test/core/core_type_mat3x3.cpp @@ -29,21 +29,37 @@ static int test_mat3x3() static int test_operators() { + int Error = 0; + glm::mat3x3 l(1.0f); glm::mat3x3 m(1.0f); glm::vec3 u(1.0f); glm::vec3 v(1.0f); + float x = 1.0f; glm::vec3 a = m * u; + Error += glm::all(glm::equal(a, glm::vec3(1.0f), glm::epsilon())) ? 0 : 1; + glm::vec3 b = v * m; - glm::mat3x3 n = x / m; + Error += glm::all(glm::equal(b, glm::vec3(1.0f), glm::epsilon())) ? 0 : 1; + + glm::mat3x3 n0(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); + glm::mat3x3 n = x / n0; + Error += glm::all(glm::equal(n, n0, glm::epsilon())) ? 0 : 1; + glm::mat3x3 o = m / x; + Error += glm::all(glm::equal(o, m, glm::epsilon())) ? 0 : 1; + glm::mat3x3 p = x * m; + Error += glm::all(glm::equal(p, m, glm::epsilon())) ? 0 : 1; + glm::mat3x3 q = m * x; bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); bool S = glm::all(glm::equal(m, l, glm::epsilon())); - return (S && !R) ? 0 : 1; + Error += (S && !R) ? 0 : 1; + + return Error; } static int test_inverse() @@ -124,7 +140,7 @@ static int test_ctr() namespace cast { template - int entry() + static int entry() { int Error = 0; @@ -137,7 +153,7 @@ namespace cast return Error; } - int test() + static int test() { int Error = 0; diff --git a/test/core/core_type_mat3x4.cpp b/test/core/core_type_mat3x4.cpp index 97d457464..75a3addde 100644 --- a/test/core/core_type_mat3x4.cpp +++ b/test/core/core_type_mat3x4.cpp @@ -14,26 +14,42 @@ #include #include -static bool test_operators() +static int test_operators() { + int Error = 0; + glm::mat3x4 l(1.0f); glm::mat3x4 m(1.0f); glm::vec3 u(1.0f); glm::vec4 v(1.0f); + float x = 1.0f; glm::vec4 a = m * u; + Error += glm::all(glm::equal(a, glm::vec4(u, 0.0f), glm::epsilon())) ? 0 : 1; + glm::vec3 b = v * m; - glm::mat3x4 n = x / m; + Error += glm::all(glm::equal(b, glm::vec3(1.0f), glm::epsilon())) ? 0 : 1; + + glm::mat3x4 n0(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); + glm::mat3x4 n = x / n0; + Error += glm::all(glm::equal(n, n0, glm::epsilon())) ? 0 : 1; + glm::mat3x4 o = m / x; + Error += glm::all(glm::equal(o, m, glm::epsilon())) ? 0 : 1; + glm::mat3x4 p = x * m; + Error += glm::all(glm::equal(p, m, glm::epsilon())) ? 0 : 1; + glm::mat3x4 q = m * x; bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); bool S = glm::all(glm::equal(m, l, glm::epsilon())); - return (S && !R) ? 0 : 1; + Error += (S && !R) ? 0 : 1; + + return Error; } -int test_ctr() +static int test_ctr() { int Error(0); @@ -79,7 +95,7 @@ int test_ctr() namespace cast { template - int entry() + static int entry() { int Error = 0; @@ -93,7 +109,7 @@ namespace cast return Error; } - int test() + static int test() { int Error = 0; diff --git a/test/core/core_type_mat4x2.cpp b/test/core/core_type_mat4x2.cpp index 7133edc81..89407f634 100644 --- a/test/core/core_type_mat4x2.cpp +++ b/test/core/core_type_mat4x2.cpp @@ -15,24 +15,40 @@ static int test_operators() { + int Error = 0; + glm::mat4x2 l(1.0f); glm::mat4x2 m(1.0f); glm::vec4 u(1.0f); glm::vec2 v(1.0f); + float x = 1.0f; glm::vec2 a = m * u; + Error += glm::all(glm::equal(a, glm::vec2(1.0f), glm::epsilon())) ? 0 : 1; + glm::vec4 b = v * m; - glm::mat4x2 n = x / m; + Error += glm::all(glm::equal(b, glm::vec4(v, 0.0f, 0.0f), glm::epsilon())) ? 0 : 1; + + glm::mat4x2 n0(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); + glm::mat4x2 n = x / n0; + Error += glm::all(glm::equal(n, n0, glm::epsilon())) ? 0 : 1; + glm::mat4x2 o = m / x; + Error += glm::all(glm::equal(o, m, glm::epsilon())) ? 0 : 1; + glm::mat4x2 p = x * m; + Error += glm::all(glm::equal(p, m, glm::epsilon())) ? 0 : 1; + glm::mat4x2 q = m * x; bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); bool S = glm::all(glm::equal(m, l, glm::epsilon())); - return (S && !R) ? 0 : 1; + Error += (S && !R) ? 0 : 1; + + return Error; } -int test_ctr() +static int test_ctr() { int Error(0); @@ -82,7 +98,7 @@ int test_ctr() namespace cast { template - int entry() + static int entry() { int Error = 0; @@ -95,7 +111,7 @@ namespace cast return Error; } - int test() + static int test() { int Error = 0; diff --git a/test/core/core_type_mat4x3.cpp b/test/core/core_type_mat4x3.cpp index 1c65e7f3f..36b8e0980 100644 --- a/test/core/core_type_mat4x3.cpp +++ b/test/core/core_type_mat4x3.cpp @@ -15,24 +15,40 @@ static int test_operators() { + int Error = 0; + glm::mat4x3 l(1.0f); glm::mat4x3 m(1.0f); glm::vec4 u(1.0f); glm::vec3 v(1.0f); + float x = 1.0f; glm::vec3 a = m * u; + Error += glm::all(glm::equal(a, glm::vec3(1.0f), glm::epsilon())) ? 0 : 1; + glm::vec4 b = v * m; - glm::mat4x3 n = x / m; + Error += glm::all(glm::equal(b, glm::vec4(v, 0.0f), glm::epsilon())) ? 0 : 1; + + glm::mat4x3 n0(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f); + glm::mat4x3 n = x / n0; + Error += glm::all(glm::equal(n, n0, glm::epsilon())) ? 0 : 1; + glm::mat4x3 o = m / x; + Error += glm::all(glm::equal(o, m, glm::epsilon())) ? 0 : 1; + glm::mat4x3 p = x * m; + Error += glm::all(glm::equal(p, m, glm::epsilon())) ? 0 : 1; + glm::mat4x3 q = m * x; bool R = glm::any(glm::notEqual(m, q, glm::epsilon())); bool S = glm::all(glm::equal(m, l, glm::epsilon())); - return (S && !R) ? 0 : 1; + Error += (S && !R) ? 0 : 1; + + return Error; } -int test_ctr() +static int test_ctr() { int Error(0); @@ -82,7 +98,7 @@ int test_ctr() namespace cast { template - int entry() + static int entry() { int Error = 0; @@ -95,7 +111,7 @@ namespace cast return Error; } - int test() + static int test() { int Error = 0; diff --git a/test/core/core_type_vec1.cpp b/test/core/core_type_vec1.cpp index 77f3f84d7..f3cd026b1 100644 --- a/test/core/core_type_vec1.cpp +++ b/test/core/core_type_vec1.cpp @@ -5,10 +5,19 @@ #include #include +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + static glm::vec1 g1; static glm::vec1 g2(1); -int test_vec1_operators() +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +#endif + +static int test_operators() { int Error = 0; @@ -36,7 +45,7 @@ int test_vec1_operators() return Error; } -int test_vec1_ctor() +static int test_ctor() { int Error = 0; @@ -72,18 +81,28 @@ int test_vec1_ctor() */ { - glm::vec2 A = glm::vec2(2.0f); - glm::vec2 B = glm::vec2(2.0f, 3.0f); - glm::vec2 C = glm::vec2(2.0f, 3.0); - //glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says? - glm::vec2 E(glm::dvec2(2.0)); - glm::vec2 F(glm::ivec2(2)); + glm::vec1 A = glm::vec2(2.0f); + Error += glm::all(glm::equal(A, glm::vec1(2.0f), glm::epsilon())) ? 0 : 1; + + glm::vec1 B = glm::vec2(2.0f, 3.0f); + Error += glm::all(glm::equal(B, glm::vec1(2.0f), glm::epsilon())) ? 0 : 1; + + glm::vec1 C = glm::vec2(2.0f, 3.0); + Error += glm::all(glm::equal(C, glm::vec1(2.0f), glm::epsilon())) ? 0 : 1; + + //glm::vec1 D = glm::dvec1(2.0); // Build error TODO: What does the specification says? + + glm::vec1 E(glm::dvec2(2.0)); + Error += glm::all(glm::equal(E, glm::vec1(2.0f), glm::epsilon())) ? 0 : 1; + + glm::vec1 F(glm::ivec2(2)); + Error += glm::all(glm::equal(F, glm::vec1(2.0f), glm::epsilon())) ? 0 : 1; } return Error; } -static int test_vec1_size() +static int test_size() { int Error = 0; @@ -99,7 +118,7 @@ static int test_vec1_size() return Error; } -static int test_vec1_operator_increment() +static int test_operator_increment() { int Error(0); @@ -158,10 +177,10 @@ int main() { int Error = 0; - Error += test_vec1_size(); - Error += test_vec1_ctor(); - Error += test_vec1_operators(); - Error += test_vec1_operator_increment(); + Error += test_size(); + Error += test_ctor(); + Error += test_operators(); + Error += test_operator_increment(); Error += test_swizzle(); Error += test_constexpr(); diff --git a/test/core/core_type_vec2.cpp b/test/core/core_type_vec2.cpp index 308c61f0d..1cf7db385 100644 --- a/test/core/core_type_vec2.cpp +++ b/test/core/core_type_vec2.cpp @@ -10,10 +10,19 @@ # include #endif +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + static glm::ivec2 g1; static glm::ivec2 g2(1); static glm::ivec2 g3(1, 1); +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +#endif + static int test_operators() { int Error = 0; @@ -240,11 +249,22 @@ static int test_ctor() { glm::vec2 A = glm::vec2(2.0f); + Error += glm::all(glm::equal(A, glm::vec2(2.0f), glm::epsilon())) ? 0 : 1; + glm::vec2 B = glm::vec2(2.0f, 3.0f); + Error += glm::all(glm::equal(B, glm::vec2(2.0f, 3.0f), glm::epsilon())) ? 0 : 1; + glm::vec2 C = glm::vec2(2.0f, 3.0); + Error += glm::all(glm::equal(C, glm::vec2(2.0f, 3.0f), glm::epsilon())) ? 0 : 1; + //glm::vec2 D = glm::dvec2(2.0); // Build error TODO: What does the specification says? + + glm::vec2 E(glm::dvec2(2.0)); + Error += glm::all(glm::equal(E, glm::vec2(2.0f), glm::epsilon())) ? 0 : 1; + glm::vec2 F(glm::ivec2(2)); + Error += glm::all(glm::equal(F, glm::vec2(2.0f), glm::epsilon())) ? 0 : 1; } { diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index 4da8187db..36d2ddfa1 100644 --- a/test/core/core_type_vec3.cpp +++ b/test/core/core_type_vec3.cpp @@ -9,11 +9,20 @@ #include #include +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + static glm::vec3 g1; static glm::vec3 g2(1); static glm::vec3 g3(1, 1, 1); -int test_vec3_ctor() +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +#endif + +static int test_vec3_ctor() { int Error = 0; @@ -291,7 +300,7 @@ static int test_vec3_operators() return Error; } -int test_vec3_size() +static int test_vec3_size() { int Error = 0; @@ -314,7 +323,7 @@ int test_vec3_size() return Error; } -int test_vec3_swizzle3_2() +static int test_vec3_swizzle3_2() { int Error = 0; @@ -378,7 +387,7 @@ int test_vec3_swizzle3_2() return Error; } -int test_vec3_swizzle3_3() +static int test_vec3_swizzle3_3() { int Error = 0; @@ -406,7 +415,7 @@ int test_vec3_swizzle3_3() return Error; } -int test_vec3_swizzle_operators() +static int test_vec3_swizzle_operators() { int Error = 0; @@ -448,7 +457,7 @@ int test_vec3_swizzle_operators() return Error; } -int test_vec3_swizzle_functions() +static int test_vec3_swizzle_functions() { int Error = 0; @@ -491,7 +500,7 @@ int test_vec3_swizzle_functions() return Error; } -int test_vec3_swizzle_partial() +static int test_vec3_swizzle_partial() { int Error = 0; diff --git a/test/core/core_type_vec4.cpp b/test/core/core_type_vec4.cpp index 5d65259f5..c7aefabd9 100644 --- a/test/core/core_type_vec4.cpp +++ b/test/core/core_type_vec4.cpp @@ -11,10 +11,19 @@ #include #include +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + static glm::vec4 g1; static glm::vec4 g2(1); static glm::vec4 g3(1, 1, 1, 1); +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +#endif + template struct mask { diff --git a/test/gtc/gtc_integer.cpp b/test/gtc/gtc_integer.cpp index 769d96903..07b59adbe 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));