mirror of
https://github.com/upx/upx.git
synced 2024-11-27 14:40:25 +00:00
src: enable -Wzero-as-null-pointer-constant when using clang
This commit is contained in:
parent
d001a63bce
commit
6931a3aa70
@ -78,8 +78,9 @@ ACC_COMPILE_TIME_ASSERT_HEADER(-1 == ~0) // two's complement - see http://wg21.l
|
|||||||
ACC_COMPILE_TIME_ASSERT_HEADER(0u-1 == ~0u) // two's complement - see http://wg21.link/P0907R4
|
ACC_COMPILE_TIME_ASSERT_HEADER(0u-1 == ~0u) // two's complement - see http://wg21.link/P0907R4
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER((1u << 31) << 1 == 0)
|
ACC_COMPILE_TIME_ASSERT_HEADER((1u << 31) << 1 == 0)
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(((int)(1u << 31)) >> 31 == -1) // arithmetic right shift
|
ACC_COMPILE_TIME_ASSERT_HEADER(((int)(1u << 31)) >> 31 == -1) // arithmetic right shift
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER((-1) >> 31 == -1) // arithmetic right shift
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255) // -funsigned-char
|
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255) // -funsigned-char
|
||||||
ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char
|
ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) == 255) // -funsigned-char
|
||||||
|
|
||||||
// enable/disable some warnings
|
// enable/disable some warnings
|
||||||
// Some non-GLIBC toolchains do not use 'nullptr' everywhere when C++:
|
// Some non-GLIBC toolchains do not use 'nullptr' everywhere when C++:
|
||||||
@ -88,6 +89,8 @@ ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char
|
|||||||
// 51:32: error: zero as null pointer constant
|
// 51:32: error: zero as null pointer constant
|
||||||
#if (ACC_CC_GNUC >= 0x040700) && defined(__GLIBC__)
|
#if (ACC_CC_GNUC >= 0x040700) && defined(__GLIBC__)
|
||||||
# pragma GCC diagnostic error "-Wzero-as-null-pointer-constant"
|
# pragma GCC diagnostic error "-Wzero-as-null-pointer-constant"
|
||||||
|
#elif (ACC_CC_CLANG >= 0x050000ul)
|
||||||
|
# pragma clang diagnostic error "-Wzero-as-null-pointer-constant"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (ACC_CC_MSC)
|
#if (ACC_CC_MSC)
|
||||||
@ -325,7 +328,7 @@ inline void NO_fprintf(FILE *, const char *, ...) {}
|
|||||||
typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \
|
typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \
|
||||||
__packed_struct(acc_tmp_t) acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z; __packed_struct_end() \
|
__packed_struct(acc_tmp_t) acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z; __packed_struct_end() \
|
||||||
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 2*sizeof(b)+sizeof(a)) \
|
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 2*sizeof(b)+sizeof(a)) \
|
||||||
COMPILE_TIME_ASSERT(sizeof(((acc_tmp_t*)0)->x)+sizeof(((acc_tmp_t*)0)->y)+sizeof(((acc_tmp_t*)0)->z) == 2*sizeof(b)+sizeof(a)) \
|
COMPILE_TIME_ASSERT(sizeof(((acc_tmp_t*)nullptr)->x)+sizeof(((acc_tmp_t*)nullptr)->y)+sizeof(((acc_tmp_t*)nullptr)->z) == 2*sizeof(b)+sizeof(a)) \
|
||||||
}
|
}
|
||||||
#if defined(__acc_alignof)
|
#if defined(__acc_alignof)
|
||||||
# define __COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
|
# define __COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
|
||||||
|
@ -4822,7 +4822,7 @@ typedef unsigned short wchar_t;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef offsetof
|
#ifndef offsetof
|
||||||
#define offsetof(s,m) ((size_t)((ptrdiff_t)&(((s*)0)->m)))
|
#define offsetof(s,m) ((size_t)((ptrdiff_t)&(((s*)nullptr)->m)))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#elif (ACC_LIBC_FREESTANDING)
|
#elif (ACC_LIBC_FREESTANDING)
|
||||||
@ -5771,9 +5771,9 @@ ACCLIB_EXTERN(int, acc_spawnve) (int mode, const char* fn, const char* const * a
|
|||||||
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(int))
|
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(int))
|
||||||
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t))
|
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t))
|
||||||
#if !(ACC_BROKEN_SIZEOF)
|
#if !(ACC_BROKEN_SIZEOF)
|
||||||
ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(ACC_STATIC_CAST(char*, 0) - ACC_STATIC_CAST(char*, 0)))
|
ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(ACC_STATIC_CAST(char*, nullptr) - ACC_STATIC_CAST(char*, nullptr)))
|
||||||
# if (ACC_HAVE_MM_HUGE_PTR)
|
# if (ACC_HAVE_MM_HUGE_PTR)
|
||||||
ACCCHK_ASSERT(4 == sizeof(ACC_STATIC_CAST(char __huge*, 0) - ACC_STATIC_CAST(char __huge*, 0)))
|
ACCCHK_ASSERT(4 == sizeof(ACC_STATIC_CAST(char __huge*, nullptr) - ACC_STATIC_CAST(char __huge*, nullptr)))
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if (ACC_SIZEOF_PTRDIFF_T > 0)
|
#if (ACC_SIZEOF_PTRDIFF_T > 0)
|
||||||
|
@ -151,8 +151,8 @@ int PeFile::readFileHeader()
|
|||||||
|
|
||||||
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 64)
|
COMPILE_TIME_ASSERT(sizeof(exe_header_t) == 64)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(exe_header_t)
|
COMPILE_TIME_ASSERT_ALIGNED1(exe_header_t)
|
||||||
COMPILE_TIME_ASSERT(sizeof(((exe_header_t*)0)->_) == 18)
|
COMPILE_TIME_ASSERT(sizeof(((exe_header_t*)nullptr)->_) == 18)
|
||||||
COMPILE_TIME_ASSERT(sizeof(((exe_header_t*)0)->__) == 34)
|
COMPILE_TIME_ASSERT(sizeof(((exe_header_t*)nullptr)->__) == 34)
|
||||||
|
|
||||||
exe_header_t h;
|
exe_header_t h;
|
||||||
int ic;
|
int ic;
|
||||||
@ -2096,8 +2096,8 @@ unsigned PeFile::stripDebug(unsigned overlaystart)
|
|||||||
|
|
||||||
COMPILE_TIME_ASSERT(sizeof(debug_dir_t) == 28)
|
COMPILE_TIME_ASSERT(sizeof(debug_dir_t) == 28)
|
||||||
COMPILE_TIME_ASSERT_ALIGNED1(debug_dir_t)
|
COMPILE_TIME_ASSERT_ALIGNED1(debug_dir_t)
|
||||||
COMPILE_TIME_ASSERT(sizeof(((debug_dir_t*)0)->_) == 16)
|
COMPILE_TIME_ASSERT(sizeof(((debug_dir_t*)nullptr)->_) == 16)
|
||||||
COMPILE_TIME_ASSERT(sizeof(((debug_dir_t*)0)->__) == 4)
|
COMPILE_TIME_ASSERT(sizeof(((debug_dir_t*)nullptr)->__) == 4)
|
||||||
|
|
||||||
unsigned const take = IDSIZE(PEDIR_DEBUG);
|
unsigned const take = IDSIZE(PEDIR_DEBUG);
|
||||||
unsigned const skip = IDADDR(PEDIR_DEBUG);
|
unsigned const skip = IDADDR(PEDIR_DEBUG);
|
||||||
@ -2166,7 +2166,7 @@ void PeFile::checkHeaderValues(unsigned subsystem, unsigned mask,
|
|||||||
if (IDSIZE(PEDIR_COMRT))
|
if (IDSIZE(PEDIR_COMRT))
|
||||||
throwCantPack(".NET files are not yet supported");
|
throwCantPack(".NET files are not yet supported");
|
||||||
|
|
||||||
if(isection == NULL)
|
if (isection == nullptr)
|
||||||
throwCantPack("No section was found");
|
throwCantPack("No section was found");
|
||||||
|
|
||||||
if (memcmp(isection[0].name,"UPX",3) == 0)
|
if (memcmp(isection[0].name,"UPX",3) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user