Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Jan 9, 2024
1 parent 9fd7ed0 commit ec79055
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 17 deletions.
9 changes: 9 additions & 0 deletions glm/detail/func_integer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,11 @@ namespace detail
return (Base & ~Mask) | ((Insert << static_cast<T>(Offset)) & Mask);
}

#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4309)
#endif

// bitfieldReverse
template<typename genIUType>
GLM_FUNC_QUALIFIER genIUType bitfieldReverse(genIUType x)
Expand All @@ -298,6 +303,10 @@ namespace detail
return x;
}

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif

// bitCount
template<typename genIUType>
GLM_FUNC_QUALIFIER int bitCount(genIUType x)
Expand Down
4 changes: 2 additions & 2 deletions glm/ext/scalar_ulp.inl
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ typedef union
do { \
ieee_float_shape_type gf_u; \
gf_u.value = (d); \
(i) = gf_u.word; \
(i) = static_cast<int>(gf_u.word); \
} while (0)

#define GLM_SET_FLOAT_WORD(d,i) \
do { \
ieee_float_shape_type sf_u; \
sf_u.word = (i); \
sf_u.word = static_cast<unsigned int>(i); \
(d) = sf_u.value; \
} while (0)

Expand Down
16 changes: 8 additions & 8 deletions glm/ext/vector_ulp.inl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace glm
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> nextFloat(vec<L, T, Q> const& x)
{
vec<L, T, Q> Result;
vec<L, T, Q> Result(0);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = nextFloat(x[i]);
return Result;
Expand All @@ -12,7 +12,7 @@ namespace glm
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, int ULPs)
{
vec<L, T, Q> Result;
vec<L, T, Q> Result(0);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = nextFloat(x[i], ULPs);
return Result;
Expand All @@ -21,7 +21,7 @@ namespace glm
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> nextFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs)
{
vec<L, T, Q> Result;
vec<L, T, Q> Result(0);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = nextFloat(x[i], ULPs[i]);
return Result;
Expand All @@ -30,7 +30,7 @@ namespace glm
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> prevFloat(vec<L, T, Q> const& x)
{
vec<L, T, Q> Result;
vec<L, T, Q> Result(0);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = prevFloat(x[i]);
return Result;
Expand All @@ -39,7 +39,7 @@ namespace glm
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, int ULPs)
{
vec<L, T, Q> Result;
vec<L, T, Q> Result(0);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = prevFloat(x[i], ULPs);
return Result;
Expand All @@ -48,7 +48,7 @@ namespace glm
template<length_t L, typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, T, Q> prevFloat(vec<L, T, Q> const& x, vec<L, int, Q> const& ULPs)
{
vec<L, T, Q> Result;
vec<L, T, Q> Result(0);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = prevFloat(x[i], ULPs[i]);
return Result;
Expand All @@ -57,7 +57,7 @@ namespace glm
template<length_t L, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, int, Q> floatDistance(vec<L, float, Q> const& x, vec<L, float, Q> const& y)
{
vec<L, int, Q> Result;
vec<L, int, Q> Result(0);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = floatDistance(x[i], y[i]);
return Result;
Expand All @@ -66,7 +66,7 @@ namespace glm
template<length_t L, qualifier Q>
GLM_FUNC_QUALIFIER vec<L, int64, Q> floatDistance(vec<L, double, Q> const& x, vec<L, double, Q> const& y)
{
vec<L, int64, Q> Result;
vec<L, int64, Q> Result(0);
for(length_t i = 0, n = Result.length(); i < n; ++i)
Result[i] = floatDistance(x[i], y[i]);
return Result;
Expand Down
4 changes: 4 additions & 0 deletions test/core/core_func_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

// This file has divisions by zero to test isnan
#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4723)
#endif

Expand Down Expand Up @@ -1347,3 +1348,6 @@ int main()
return Error;
}

#if(GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(pop)
#endif
18 changes: 18 additions & 0 deletions test/core/core_func_integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ namespace bitfieldReverse
}
};

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4309)
# endif

template<glm::length_t L, typename T, glm::qualifier Q>
GLM_FUNC_QUALIFIER glm::vec<L, T, Q> bitfieldReverseOps(glm::vec<L, T, Q> const& v)
{
Expand All @@ -236,6 +241,10 @@ namespace bitfieldReverse
return x;
}

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif

template<typename genType>
GLM_FUNC_QUALIFIER genType bitfieldReverseOps(genType x)
{
Expand Down Expand Up @@ -1423,6 +1432,11 @@ namespace bitCount
}
};

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4309)
# endif

template<glm::length_t L, typename T, glm::qualifier Q>
static glm::vec<L, int, Q> bitCount_bitfield(glm::vec<L, T, Q> const& v)
{
Expand All @@ -1436,6 +1450,10 @@ namespace bitCount
return glm::vec<L, int, Q>(x);
}

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif

template<typename genType>
static int bitCount_bitfield(genType x)
{
Expand Down
15 changes: 15 additions & 0 deletions test/core/core_func_integer_find_lsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ execute in only 10 cycles on a machine with sufficient parallelism.
useful parallelism on most machines (the assignments to y, bz, and b4
could then all run in parallel). */

#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4146)
#endif

int ntz7(unsigned x)
{
unsigned y, bz, b4, b3, b2, b1, b0;
Expand All @@ -152,9 +157,15 @@ int ntz7(unsigned x)
return bz + b4 + b3 + b2 + b1 + b0;
}

#if(GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(pop)
#endif

// This file has divisions by zero to test isnan
#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4800)
# pragma warning(disable : 4146)
#endif

int ntz7_christophe(unsigned x)
Expand Down Expand Up @@ -264,6 +275,10 @@ int ntz11 (unsigned int n) {
return n ? tab[k>>27] : 32;
}

#if(GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(pop)
#endif

int errors;
void error(int x, int y) {
errors = errors + 1;
Expand Down
9 changes: 9 additions & 0 deletions test/core/core_func_integer_find_msb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ L: if (x < 0) return n;
goto L;
}

#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4146)
#endif

int nlz4(unsigned x) {
int y, m, n;

Expand Down Expand Up @@ -111,6 +116,10 @@ int nlz4(unsigned x) {
return n + 2 - m;
}

#if(GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(pop)
#endif

int nlz5(unsigned x) {
int pop(unsigned x);

Expand Down
7 changes: 4 additions & 3 deletions test/core/core_setup_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,12 @@ int test_model()

Error += ((sizeof(void*) == 4) && (GLM_MODEL == GLM_MODEL_32)) || ((sizeof(void*) == 8) && (GLM_MODEL == GLM_MODEL_64)) ? 0 : 1;

if(GLM_MODEL == GLM_MODEL_32)
# if GLM_MODEL == GLM_MODEL_32
std::printf("GLM_MODEL_32\n");
else if(GLM_MODEL == GLM_MODEL_64)
# elif GLM_MODEL == GLM_MODEL_64
std::printf("GLM_MODEL_64\n");

# endif

return Error;
}

Expand Down
7 changes: 7 additions & 0 deletions test/ext/ext_scalar_integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ namespace nextMultiple
return Result > 0 ? 0 : 1;
}

#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4146)
#endif
template <typename T>
GLM_FUNC_QUALIFIER T nextMultipleNeg(T Source, T Multiple)
{
Expand All @@ -438,6 +442,9 @@ namespace nextMultiple
else
return Source + (-Source % Multiple);
}
#if(GLM_COMPILER & GLM_COMPILER_VC)
# pragma warning(pop)
#endif

int perf_nextMultipleNeg(glm::uint Samples)
{
Expand Down
12 changes: 8 additions & 4 deletions test/gtc/gtc_bitfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,25 @@ namespace mask
*/
for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_mix(Data[i].Value);
glm::uint Result = static_cast<glm::uint>(mask_mix(Data[i].Value));
Error += Data[i].Return == Result ? 0 : 1;
}

for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_half(Data[i].Value);
glm::uint Result = static_cast<glm::uint>(mask_half(Data[i].Value));
Error += Data[i].Return == Result ? 0 : 1;
}

for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = mask_loop(Data[i].Value);
glm::uint Result = static_cast<glm::uint>(mask_loop(Data[i].Value));
Error += Data[i].Return == Result ? 0 : 1;
}

for(std::size_t i = 0; i < sizeof(Data) / sizeof(type<int>); ++i)
{
int Result = glm::mask(Data[i].Value);
glm::uint Result = static_cast<glm::uint>(glm::mask(Data[i].Value));
Error += Data[i].Return == Result ? 0 : 1;
}

Expand Down Expand Up @@ -687,6 +687,10 @@ namespace bitfieldInterleave5
(Result >> 48) & 0xFFFF000000000000ull);
}

#if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(disable : 4309)
#endif

GLM_FUNC_QUALIFIER glm::uint32 bitfieldInterleave_u16vec2(glm::uint16 x, glm::uint16 y)
{
glm::uint64 Result = (glm::uint64(y) << 32) | glm::uint64(x);
Expand Down
27 changes: 27 additions & 0 deletions test/gtx/gtx_type_aligned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,42 @@ int test_decl()
glm::vec3 B;
};

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4324)
# endif

struct S2
{
bool A;
glm::aligned_vec3 B;
};

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif

std::printf("vec3 - Aligned: %d, unaligned: %d\n", static_cast<int>(sizeof(S1)), static_cast<int>(sizeof(S2)));

Error += sizeof(S1) <= sizeof(S2) ? 0 : 1;
}

{
# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4324)
# endif

struct S1
{
bool A;
glm::aligned_vec4 B;
};

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif

struct S2
{
bool A;
Expand All @@ -59,12 +77,21 @@ int test_decl()
}

{
# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(push)
# pragma warning(disable : 4324)
# endif

struct S1
{
bool A;
glm::aligned_dvec4 B;
};

# if GLM_COMPILER & GLM_COMPILER_VC
# pragma warning(pop)
# endif

struct S2
{
bool A;
Expand Down

0 comments on commit ec79055

Please sign in to comment.