mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 23:26:24 +00:00
clang/gcc: enable a bunch more warnings (#91)
* clang/gcc: enable -pedantic warnings * suppress a GCC-specific warning in stb_image * And some clang-specific warnings * -Wconversion (clang) -Wold-style-cast (clang+gcc) and fix a few warnings that show up with these (and a few more with -Wconversion on gcc, even though that's not enabled by default) * bunch more warnings * fixes * remove merge error
This commit is contained in:
@@ -28,7 +28,7 @@ uint32_t ScanForward(uint32_t bits) {
|
||||
ASSERT(ret != 0);
|
||||
return firstBitIndex;
|
||||
#else
|
||||
return static_cast<unsigned long>(__builtin_ctz(bits));
|
||||
return static_cast<uint32_t>(__builtin_ctz(bits));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ uint32_t Log2(uint32_t value) {
|
||||
ASSERT(ret != 0);
|
||||
return firstBitIndex;
|
||||
#else
|
||||
return 31 - __builtin_clz(value);
|
||||
return 31 - static_cast<uint32_t>(__builtin_clz(value));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ bool IsPowerOfTwo(size_t n) {
|
||||
bool IsAligned(const void* ptr, size_t alignment) {
|
||||
ASSERT(IsPowerOfTwo(alignment));
|
||||
ASSERT(alignment != 0);
|
||||
return (reinterpret_cast<intptr_t>(ptr) & (alignment - 1)) == 0;
|
||||
return (reinterpret_cast<size_t>(ptr) & (alignment - 1)) == 0;
|
||||
}
|
||||
|
||||
void* AlignVoidPtr(void* ptr, size_t alignment) {
|
||||
ASSERT(IsPowerOfTwo(alignment));
|
||||
ASSERT(alignment != 0);
|
||||
return reinterpret_cast<void*>((reinterpret_cast<intptr_t>(ptr) + (alignment - 1)) & ~(alignment - 1));
|
||||
return reinterpret_cast<void*>((reinterpret_cast<size_t>(ptr) + (alignment - 1)) & ~(alignment - 1));
|
||||
}
|
||||
|
||||
uint32_t Align(uint32_t value, size_t alignment) {
|
||||
|
||||
Reference in New Issue
Block a user