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..9858dc0580 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 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/CMakeLists.txt b/test/CMakeLists.txt index 0624008cf9..ffce84a867 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -209,10 +209,12 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(NOT GLM_DISABLE_AUTO_DETECTION) add_compile_options(-Werror) + add_compile_options(-Wpedantic) + add_compile_options(-Wall) + add_compile_options(-Wextra) endif() add_compile_options(-O2) - add_compile_options(-Wno-long-long) - + #add_compile_options(-Wno-long-long) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") if(NOT GLM_QUIET) message("GLM: Intel - ${CMAKE_CXX_COMPILER_ID} compiler") 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..33284d09b0 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_common.cpp b/test/core/core_func_common.cpp index 5d9295e1f1..bc09af1fcf 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -298,12 +298,12 @@ namespace min_ return Error; } - int min_tern(int a, int b) + static int min_tern(int a, int b) { return a < b ? a : b; } - int min_int(int x, int y) + static int min_int(int x, int y) { return y ^ ((x ^ y) & -(x < y)); } @@ -397,6 +397,11 @@ namespace clamp_ namespace mix_ { +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +#endif + template struct entry { @@ -406,7 +411,16 @@ namespace mix_ T Result; }; - entry const TestBool[] = +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +#endif + +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + + static entry const TestBool[] = { {0.0f, 1.0f, false, 0.0f}, {0.0f, 1.0f, true, 1.0f}, @@ -414,7 +428,7 @@ namespace mix_ {-1.0f, 1.0f, true, 1.0f} }; - entry const TestFloat[] = + static entry const TestFloat[] = { {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 1.0f, 1.0f}, @@ -422,7 +436,7 @@ namespace mix_ {-1.0f, 1.0f, 1.0f, 1.0f} }; - entry const TestVec2Bool[] = + static entry const TestVec2Bool[] = { {glm::vec2(0.0f), glm::vec2(1.0f), false, glm::vec2(0.0f)}, {glm::vec2(0.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)}, @@ -430,7 +444,7 @@ namespace mix_ {glm::vec2(-1.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)} }; - entry const TestBVec2[] = + static entry const TestBVec2[] = { {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(0.0f)}, {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)}, @@ -439,7 +453,7 @@ namespace mix_ {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true, false), glm::vec2(1.0f, -1.0f)} }; - entry const TestVec3Bool[] = + static entry const TestVec3Bool[] = { {glm::vec3(0.0f), glm::vec3(1.0f), false, glm::vec3(0.0f)}, {glm::vec3(0.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)}, @@ -447,7 +461,7 @@ namespace mix_ {glm::vec3(-1.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)} }; - entry const TestBVec3[] = + static entry const TestBVec3[] = { {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(0.0f)}, {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)}, @@ -456,7 +470,7 @@ namespace mix_ {glm::vec3(1.0f, 2.0f, 3.0f), glm::vec3(4.0f, 5.0f, 6.0f), glm::bvec3(true, false, true), glm::vec3(4.0f, 2.0f, 6.0f)} }; - entry const TestVec4Bool[] = + static entry const TestVec4Bool[] = { {glm::vec4(0.0f), glm::vec4(1.0f), false, glm::vec4(0.0f)}, {glm::vec4(0.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)}, @@ -464,7 +478,7 @@ namespace mix_ {glm::vec4(-1.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)} }; - entry const TestBVec4[] = + static entry const TestBVec4[] = { {glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), glm::vec4(2.0f, 2.0f, 3.0f, 3.0f), glm::bvec4(false, true, false, true), glm::vec4(0.0f, 2.0f, 1.0f, 3.0f)}, {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)}, @@ -473,6 +487,10 @@ namespace mix_ {glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(5.0f, 6.0f, 7.0f, 8.0f), glm::bvec4(true, false, true, false), glm::vec4(5.0f, 2.0f, 7.0f, 4.0f)} }; +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +#endif + static int test() { int Error = 0; @@ -575,14 +593,19 @@ namespace step_ VEC result; }; - entry TestVec4Scalar [] = +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + + static const entry TestVec4Scalar [] = { { 1.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, { 0.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, { 0.0f, glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(0.0f) } }; - entry TestVec4Vector [] = + static const entry TestVec4Vector [] = { { glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(-2.0f, -3.0f, -4.0f, -5.0f), glm::vec4(0.0f) }, { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, @@ -590,6 +613,10 @@ namespace step_ { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4(-1.0f,-2.0f,-3.0f,-4.0f), glm::vec4(0.0f) } }; +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +#endif + static int test() { int Error = 0; @@ -901,6 +928,11 @@ namespace sign return result; } +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wsign-conversion" +#endif + template GLM_FUNC_QUALIFIER genFIType sign_alu1(genFIType x) { @@ -911,6 +943,10 @@ namespace sign return (x >> 31) | (static_cast(-x) >> 31); } +#if GLM_COMPILER & GLM_COMPILER_CLANG +# pragma clang diagnostic pop +#endif + GLM_FUNC_QUALIFIER int sign_alu2(int x) { GLM_STATIC_ASSERT(std::numeric_limits::is_signed && std::numeric_limits::is_integer, "'sign' only accept integer inputs"); @@ -954,7 +990,7 @@ namespace sign genType Return; }; - int test_int32() + static int test_int32() { type const Data[] = { @@ -1004,7 +1040,7 @@ namespace sign return Error; } - int test_i32vec4() + static int test_i32vec4() { type const Data[] = { @@ -1028,7 +1064,7 @@ namespace sign return Error; } - int test_f32vec4() + static int test_f32vec4() { type const Data[] = { @@ -1063,7 +1099,7 @@ namespace sign return Error; } - int perf_rand(std::size_t Samples) + static int perf_rand(std::size_t Samples) { int Error = 0; @@ -1116,7 +1152,7 @@ namespace sign return Error; } - int perf_linear(std::size_t Samples) + static int perf_linear(std::size_t Samples) { int Error = 0; @@ -1163,7 +1199,7 @@ namespace sign return Error; } - int perf_linear_cal(std::size_t Samples) + static int perf_linear_cal(std::size_t Samples) { int Error = 0; diff --git a/test/core/core_func_geometric.cpp b/test/core/core_func_geometric.cpp index 7ef9c6838a..9e3e6d21a0 100644 --- a/test/core/core_func_geometric.cpp +++ b/test/core/core_func_geometric.cpp @@ -13,7 +13,7 @@ namespace length { - int test() + static int test() { float Length1 = glm::length(glm::vec1(1)); float Length2 = glm::length(glm::vec2(1, 0)); @@ -33,7 +33,7 @@ namespace length namespace distance { - int test() + static int test() { float Distance1 = glm::distance(glm::vec1(1), glm::vec1(1)); float Distance2 = glm::distance(glm::vec2(1, 0), glm::vec2(1, 0)); @@ -53,7 +53,7 @@ namespace distance namespace dot { - int test() + static int test() { float Dot1 = glm::dot(glm::vec1(1), glm::vec1(1)); float Dot2 = glm::dot(glm::vec2(1), glm::vec2(1)); @@ -73,7 +73,7 @@ namespace dot namespace cross { - int test() + static int test() { glm::vec3 Cross1 = glm::cross(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0)); glm::vec3 Cross2 = glm::cross(glm::vec3(0, 1, 0), glm::vec3(1, 0, 0)); @@ -89,22 +89,23 @@ namespace cross namespace normalize { - int test() + static int test() { + int Error = 0; + glm::vec3 Normalize1 = glm::normalize(glm::vec3(1, 0, 0)); glm::vec3 Normalize2 = glm::normalize(glm::vec3(2, 0, 0)); - glm::vec3 Normalize3 = glm::normalize(glm::vec3(-0.6, 0.7, -0.5)); + Error += glm::all(glm::lessThan(glm::abs(Normalize1 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits::epsilon()))) ? 0 : 1; + Error += glm::all(glm::lessThan(glm::abs(Normalize2 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits::epsilon()))) ? 0 : 1; glm::vec3 ro = glm::vec3(glm::cos(5.f) * 3.f, 2.f, glm::sin(5.f) * 3.f); glm::vec3 w = glm::normalize(glm::vec3(0, -0.2f, 0) - ro); glm::vec3 u = glm::normalize(glm::cross(w, glm::vec3(0, 1, 0))); glm::vec3 v = glm::cross(u, w); + glm::vec3 x = glm::cross(w, u); - int Error = 0; - - Error += glm::all(glm::lessThan(glm::abs(Normalize1 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits::epsilon()))) ? 0 : 1; - Error += glm::all(glm::lessThan(glm::abs(Normalize2 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits::epsilon()))) ? 0 : 1; + Error += glm::all(glm::equal(x + v, glm::vec3(0), 0.01f)) ? 0 : 1; return Error; } @@ -112,7 +113,7 @@ namespace normalize namespace faceforward { - int test() + static int test() { int Error = 0; @@ -129,7 +130,7 @@ namespace faceforward namespace reflect { - int test() + static int test() { int Error = 0; @@ -153,7 +154,7 @@ namespace reflect namespace refract { - int test() + static int test() { 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..59a00d74c1 100644 --- a/test/core/core_func_integer_find_lsb.cpp +++ b/test/core/core_func_integer_find_lsb.cpp @@ -3,7 +3,9 @@ #include //To define "exit", req'd by XLC. #include -int nlz(unsigned x) +#ifdef NDEBUG + +static int nlz(unsigned x) { int pop(unsigned x); @@ -15,7 +17,7 @@ int nlz(unsigned x) return pop(~x); } -int pop(unsigned x) +static int pop(unsigned x) { x = x - ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x33333333); @@ -25,17 +27,17 @@ int pop(unsigned x) return x >> 24; } -int ntz1(unsigned x) +static int ntz1(unsigned x) { return 32 - nlz(~x & (x-1)); } -int ntz2(unsigned x) +static int ntz2(unsigned x) { return pop(~x & (x - 1)); } -int ntz3(unsigned x) +static int ntz3(unsigned x) { int n; @@ -48,7 +50,7 @@ int ntz3(unsigned x) return n - (x & 1); } -int ntz4(unsigned x) +static int ntz4(unsigned x) { unsigned y; int n; @@ -63,7 +65,7 @@ int ntz4(unsigned x) return n; } -int ntz4a(unsigned x) +static int ntz4a(unsigned x) { unsigned y; int n; @@ -78,7 +80,7 @@ int ntz4a(unsigned x) return n; } -int ntz5(char x) +static int ntz5(char x) { if (x & 15) { if (x & 3) { @@ -97,7 +99,7 @@ int ntz5(char x) else return 8; } -int ntz6(unsigned x) +static int ntz6(unsigned x) { int n; @@ -111,7 +113,7 @@ int ntz6(unsigned x) return n; // return n; } -int ntz6a(unsigned x) +static int ntz6a(unsigned x) { int n = 32; @@ -143,7 +145,7 @@ could then all run in parallel). */ # pragma warning(disable : 4146) #endif -int ntz7(unsigned x) +static int ntz7(unsigned x) { unsigned y, bz, b4, b3, b2, b1, b0; @@ -168,7 +170,7 @@ int ntz7(unsigned x) # pragma warning(disable : 4146) #endif -int ntz7_christophe(unsigned x) +static int ntz7_christophe(unsigned x) { unsigned y, bz, b4, b3, b2, b1, b0; @@ -188,7 +190,7 @@ entries marked "u" are unused. 6 ops including a multiply, plus an indexed load. */ #define u 99 -int ntz8(unsigned x) +static int ntz8(unsigned x) { static char table[64] = {32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14, @@ -203,7 +205,7 @@ int ntz8(unsigned x) /* Seal's algorithm with multiply expanded. 9 elementary ops plus an indexed load. */ -int ntz8a(unsigned x) +static int ntz8a(unsigned x) { static char table[64] = {32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14, @@ -221,7 +223,7 @@ int ntz8a(unsigned x) /* Reiser's algorithm. Three ops including a "remainder," plus an indexed load. */ -int ntz9(unsigned x) +static int ntz9(unsigned x) { static char table[37] = { 32, 0, 1, 26, 2, 23, 27, @@ -239,7 +241,7 @@ table. The de Bruijn sequence used here is obtained from Danny Dube's October 3, 1997, posting in comp.compression.research. Thanks to Norbert Juffa for this reference. */ -int ntz10(unsigned x) { +static int ntz10(unsigned x) { static char table[32] = { 0, 1, 2,24, 3,19, 6,25, 22, 4,20,10,16, 7,12,26, @@ -253,7 +255,7 @@ int ntz10(unsigned x) { /* Norbert Juffa's code, answer to exercise 1 of Chapter 5 (2nd ed). */ #define SLOW_MUL -int ntz11 (unsigned int n) { +static int ntz11 (unsigned int n) { static unsigned char tab[32] = { 0, 1, 2, 24, 3, 19, 6, 25, @@ -280,15 +282,18 @@ int ntz11 (unsigned int n) { #endif int errors; -void error(int x, int y) { +static void error(int x, int y) { errors = errors + 1; 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 - int i, m, n; static unsigned test[] = {0,32, 1,0, 2,1, 3,0, 4,2, 5,0, 6,1, 7,0, 8,3, 9,0, 16,4, 32,5, 64,6, 128,7, 255,0, 256,8, 512,9, 1024,10, @@ -426,6 +431,17 @@ int main() if (errors == 0) std::printf("Passed all %d cases.\n", static_cast(sizeof(test)/8)); +} + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + +#else -# endif//NDEBUG +int main() +{ + return 0; } + +#endif//NDEBUG diff --git a/test/core/core_func_integer_find_msb.cpp b/test/core/core_func_integer_find_msb.cpp index 61bee61f09..2de9b7eeed 100644 --- a/test/core/core_func_integer_find_msb.cpp +++ b/test/core/core_func_integer_find_msb.cpp @@ -5,7 +5,9 @@ #define LE 1 // 1 for little-endian, 0 for big-endian. -int pop(unsigned x) { +#ifdef NDEBUG + +static int pop(unsigned x) { x = x - ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x33333333); x = (x + (x >> 4)) & 0x0F0F0F0F; @@ -14,7 +16,7 @@ int pop(unsigned x) { return x >> 24; } -int nlz1(unsigned x) { +static int nlz1(unsigned x) { int n; if (x == 0) return(32); @@ -27,7 +29,7 @@ int nlz1(unsigned x) { return n; } -int nlz1a(unsigned x) { +static int nlz1a(unsigned x) { int n; /* if (x == 0) return(32); */ @@ -42,7 +44,7 @@ int nlz1a(unsigned x) { } // On basic Risc, 12 to 20 instructions. -int nlz2(unsigned x) { +static int nlz2(unsigned x) { unsigned y; int n; @@ -57,7 +59,7 @@ int nlz2(unsigned x) { // As above but coded as a loop for compactness: // 23 to 33 basic Risc instructions. -int nlz2a(unsigned x) { +static int nlz2a(unsigned x) { unsigned y; int n, c; @@ -70,7 +72,7 @@ int nlz2a(unsigned x) { return n - x; } -int nlz3(int x) { +static int nlz3(int x) { int y, n; n = 0; @@ -88,7 +90,7 @@ L: if (x < 0) return n; # pragma warning(disable : 4146) #endif -int nlz4(unsigned x) { +static int nlz4(unsigned x) { int y, m, n; y = -(x >> 16); // If left half of x is 0, @@ -120,7 +122,7 @@ int nlz4(unsigned x) { # pragma warning(pop) #endif -int nlz5(unsigned x) { +static int nlz5(unsigned x) { int pop(unsigned x); x = x | (x >> 1); @@ -147,7 +149,7 @@ gcc/AIX, and gcc/NT, at some optimization levels. BTW, these programs use the "anonymous union" feature of C++, not available in C. */ -int nlz6(unsigned k) +static int nlz6(unsigned k) { union { unsigned asInt[2]; @@ -160,7 +162,7 @@ int nlz6(unsigned k) return n; } -int nlz7(unsigned k) +static int nlz7(unsigned k) { union { unsigned asInt[2]; @@ -183,7 +185,7 @@ int nlz7(unsigned k) FFFFFF80 <= k <= FFFFFFFF. For k = 0 it gives 158, and for the other values it is too low by 1. */ -int nlz8(unsigned k) +static int nlz8(unsigned k) { union { unsigned asInt; @@ -205,7 +207,7 @@ expressions (see "Using and Porting GNU CC", by Richard M. Stallman possibility that the macro argument will conflict with one of its local variables, e.g., NLZ(k). */ -int nlz9(unsigned k) +static int nlz9(unsigned k) { union { unsigned asInt; @@ -239,7 +241,7 @@ multiplication expanded into shifts and adds, but the table size is getting a bit large). */ #define u 99 -int nlz10(unsigned x) +static int nlz10(unsigned x) { static char table[64] = {32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u, @@ -259,7 +261,7 @@ int nlz10(unsigned x) /* Harley's algorithm with multiply expanded. 19 elementary ops plus an indexed load. */ -int nlz10a(unsigned x) +static int nlz10a(unsigned x) { static char table[64] = {32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u, @@ -283,7 +285,7 @@ int nlz10a(unsigned x) 17 elementary ops plus an indexed load, if the machine has "and not." */ -int nlz10b(unsigned x) +static int nlz10b(unsigned x) { static char table[64] = {32,20,19, u, u,18, u, 7, 10,17, u, u,14, u, 6, u, @@ -304,16 +306,19 @@ int nlz10b(unsigned x) } int errors; -void error(int x, int y) +static void error(int x, int y) { errors = errors + 1; 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 - int i, n; static unsigned test[] = {0,32, 1,31, 2,30, 3,30, 4,29, 5,29, 6,29, 7,29, 8,28, 9,28, 16,27, 32,26, 64,25, 128,24, 255,24, 256,23, @@ -444,6 +449,17 @@ int main() if (errors == 0) std::printf("Passed all %d cases.\n", static_cast(sizeof(test)/8)); +} -# endif//NDEBUG +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + +#else + +int main() +{ + return 0; } + +#endif//NDEBUG diff --git a/test/core/core_func_matrix.cpp b/test/core/core_func_matrix.cpp index b66ee7d66b..d40908cae3 100644 --- a/test/core/core_func_matrix.cpp +++ b/test/core/core_func_matrix.cpp @@ -16,7 +16,7 @@ using namespace glm; -int test_matrixCompMult() +static int test_matrixCompMult() { int Error(0); @@ -86,7 +86,7 @@ int test_matrixCompMult() return Error; } -int test_outerProduct() +static int test_outerProduct() { { glm::mat2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec2(1.0f)); } { glm::mat3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec3(1.0f)); } @@ -104,7 +104,7 @@ int test_outerProduct() return 0; } -int test_transpose() +static int test_transpose() { int Error(0); @@ -174,14 +174,14 @@ int test_transpose() return Error; } -int test_determinant() +static int test_determinant() { return 0; } -int test_inverse() +static int test_inverse() { int Error = 0; @@ -221,7 +221,7 @@ int test_inverse() return Error; } -int test_inverse_simd() +static int test_inverse_simd() { int Error = 0; @@ -240,7 +240,7 @@ int test_inverse_simd() return Error; } -int test_shearing() +static int test_shearing() { int Error = 0; @@ -320,7 +320,7 @@ int test_shearing() } template -int test_inverse_perf(std::size_t Count, std::size_t Instance, char const * Message) +static int test_inverse_perf(std::size_t Count, std::size_t Instance, char const * Message) { std::vector TestInputs; TestInputs.resize(Count); diff --git a/test/core/core_func_packing.cpp b/test/core/core_func_packing.cpp index c3cd14a205..8ec51fd47d 100644 --- a/test/core/core_func_packing.cpp +++ b/test/core/core_func_packing.cpp @@ -4,7 +4,7 @@ #include #include -int test_packUnorm2x16() +static int test_packUnorm2x16() { int Error = 0; @@ -25,7 +25,7 @@ int test_packUnorm2x16() return Error; } -int test_packSnorm2x16() +static int test_packSnorm2x16() { int Error = 0; @@ -46,7 +46,7 @@ int test_packSnorm2x16() return Error; } -int test_packUnorm4x8() +static int test_packUnorm4x8() { int Error = 0; @@ -72,7 +72,7 @@ int test_packUnorm4x8() return Error; } -int test_packSnorm4x8() +static int test_packSnorm4x8() { int Error = 0; @@ -92,7 +92,7 @@ int test_packSnorm4x8() return Error; } -int test_packHalf2x16() +static int test_packHalf2x16() { int Error = 0; /* @@ -119,7 +119,7 @@ int test_packHalf2x16() return Error; } -int test_packDouble2x32() +static int test_packDouble2x32() { int Error = 0; diff --git a/test/core/core_func_swizzle.cpp b/test/core/core_func_swizzle.cpp index 9758533f9d..f7ab67801d 100644 --- a/test/core/core_func_swizzle.cpp +++ b/test/core/core_func_swizzle.cpp @@ -44,7 +44,7 @@ static int test_ivec2_swizzle() return Error; } -int test_ivec3_swizzle() +static int test_ivec3_swizzle() { int Error = 0; @@ -109,7 +109,7 @@ int test_ivec3_swizzle() return Error; } -int test_ivec4_swizzle() +static int test_ivec4_swizzle() { int Error = 0; @@ -127,7 +127,7 @@ int test_ivec4_swizzle() return Error; } -int test_vec4_swizzle() +static int test_vec4_swizzle() { int Error = 0; diff --git a/test/core/core_type_cast.cpp b/test/core/core_type_cast.cpp index 7ff1901e1a..0f136ac432 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 2f8b018f69..ac1d876b44 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 e3ad76bbca..0e9737df39 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 ade3a44441..623f03daa7 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 7a40f90f88..a11a4b2177 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 99e1f41e06..d79ffeedc0 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 97d4574641..75a3addde0 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 7133edc812..89407f634d 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 1c65e7f3ff..36b8e09802 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 77f3f84d78..f3cd026b10 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 308c61f0dd..c82174a220 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; } { @@ -301,7 +321,7 @@ static int test_size() Error += glm::vec2::length() == 2 ? 0 : 1; Error += glm::dvec2::length() == 2 ? 0 : 1; - GLM_CONSTEXPR std::size_t Length = glm::vec2::length(); + GLM_CONSTEXPR glm::length_t Length = glm::vec2::length(); Error += Length == 2 ? 0 : 1; return Error; diff --git a/test/core/core_type_vec3.cpp b/test/core/core_type_vec3.cpp index 4da8187db9..af7eeee47e 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; @@ -125,13 +134,6 @@ int test_vec3_ctor() return Error; } -float foo() -{ - glm::vec3 bar = glm::vec3(0.0f, 1.0f, 1.0f); - - return glm::length(bar); -} - static int test_bvec3_ctor() { int Error = 0; @@ -291,7 +293,7 @@ static int test_vec3_operators() return Error; } -int test_vec3_size() +static int test_vec3_size() { int Error = 0; @@ -308,13 +310,13 @@ int test_vec3_size() Error += glm::vec3::length() == 3 ? 0 : 1; Error += glm::dvec3::length() == 3 ? 0 : 1; - GLM_CONSTEXPR std::size_t Length = glm::vec3::length(); + GLM_CONSTEXPR glm::length_t Length = glm::vec3::length(); Error += Length == 3 ? 0 : 1; return Error; } -int test_vec3_swizzle3_2() +static int test_vec3_swizzle3_2() { int Error = 0; @@ -378,7 +380,7 @@ int test_vec3_swizzle3_2() return Error; } -int test_vec3_swizzle3_3() +static int test_vec3_swizzle3_3() { int Error = 0; @@ -406,15 +408,15 @@ int test_vec3_swizzle3_3() return Error; } -int test_vec3_swizzle_operators() +static int test_vec3_swizzle_operators() { int Error = 0; - glm::ivec3 const u = glm::ivec3(1, 2, 3); - glm::ivec3 const v = glm::ivec3(10, 20, 30); - # if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR { + glm::ivec3 const u = glm::ivec3(1, 2, 3); + glm::ivec3 const v = glm::ivec3(10, 20, 30); + glm::ivec3 q; // Swizzle, swizzle binary operators @@ -448,7 +450,7 @@ int test_vec3_swizzle_operators() return Error; } -int test_vec3_swizzle_functions() +static int test_vec3_swizzle_functions() { int Error = 0; @@ -491,7 +493,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 5d65259f57..27daea6980 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 { @@ -484,9 +493,9 @@ static int test_swizzle_partial() { int Error = 0; +# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR glm::vec4 const A(1, 2, 3, 4); -# if GLM_CONFIG_SWIZZLE == GLM_SWIZZLE_OPERATOR { glm::vec4 B(A.xy, A.zw); Error += glm::all(glm::equal(A, B, glm::epsilon())) ? 0 : 1; diff --git a/test/ext/ext_matrix_integer.cpp b/test/ext/ext_matrix_integer.cpp index c26d557f5f..91418d8679 100644 --- a/test/ext/ext_matrix_integer.cpp +++ b/test/ext/ext_matrix_integer.cpp @@ -12,7 +12,7 @@ using namespace glm; -int test_matrixCompMult() +static int test_matrixCompMult() { int Error = 0; @@ -82,7 +82,7 @@ int test_matrixCompMult() return Error; } -int test_outerProduct() +static int test_outerProduct() { int Error = 0; @@ -129,7 +129,7 @@ int test_outerProduct() return Error; } -int test_transpose() +static int test_transpose() { int Error = 0; @@ -199,7 +199,7 @@ int test_transpose() return Error; } -int test_determinant() +static int test_determinant() { int Error = 0; diff --git a/test/ext/ext_quaternion_exponential.cpp b/test/ext/ext_quaternion_exponential.cpp index fbcdbeff74..7cc70dff88 100644 --- a/test/ext/ext_quaternion_exponential.cpp +++ b/test/ext/ext_quaternion_exponential.cpp @@ -11,7 +11,7 @@ #include template -int test_log() +static int test_log() { typedef typename quaType::value_type T; @@ -30,7 +30,7 @@ int test_log() } template -int test_pow() +static int test_pow() { typedef typename quaType::value_type T; diff --git a/test/ext/ext_vec1.cpp b/test/ext/ext_vec1.cpp index fc0b931878..de676608ce 100644 --- a/test/ext/ext_vec1.cpp +++ b/test/ext/ext_vec1.cpp @@ -76,7 +76,7 @@ static int test_vec1_size() Error += glm::vec1::length() == 1 ? 0 : 1; Error += glm::dvec1::length() == 1 ? 0 : 1; - GLM_CONSTEXPR std::size_t Length = glm::vec1::length(); + GLM_CONSTEXPR glm::length_t Length = glm::vec1::length(); Error += Length == 1 ? 0 : 1; return Error; 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));