Index: clang/lib/Headers/emmintrin.h =================================================================== --- clang/lib/Headers/emmintrin.h +++ clang/lib/Headers/emmintrin.h @@ -4970,10 +4970,10 @@ #define _MM_SHUFFLE2(x, y) (((x) << 1) | (y)) -#define _MM_DENORMALS_ZERO_ON (0x0040) -#define _MM_DENORMALS_ZERO_OFF (0x0000) +#define _MM_DENORMALS_ZERO_ON (0x0040U) +#define _MM_DENORMALS_ZERO_OFF (0x0000U) -#define _MM_DENORMALS_ZERO_MASK (0x0040) +#define _MM_DENORMALS_ZERO_MASK (0x0040U) #define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK) #define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & ~_MM_DENORMALS_ZERO_MASK) | (x))) Index: clang/lib/Headers/xmmintrin.h =================================================================== --- clang/lib/Headers/xmmintrin.h +++ clang/lib/Headers/xmmintrin.h @@ -2931,31 +2931,31 @@ #define _MM_SHUFFLE(z, y, x, w) (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) -#define _MM_EXCEPT_INVALID (0x0001) -#define _MM_EXCEPT_DENORM (0x0002) -#define _MM_EXCEPT_DIV_ZERO (0x0004) -#define _MM_EXCEPT_OVERFLOW (0x0008) -#define _MM_EXCEPT_UNDERFLOW (0x0010) -#define _MM_EXCEPT_INEXACT (0x0020) -#define _MM_EXCEPT_MASK (0x003f) - -#define _MM_MASK_INVALID (0x0080) -#define _MM_MASK_DENORM (0x0100) -#define _MM_MASK_DIV_ZERO (0x0200) -#define _MM_MASK_OVERFLOW (0x0400) -#define _MM_MASK_UNDERFLOW (0x0800) -#define _MM_MASK_INEXACT (0x1000) -#define _MM_MASK_MASK (0x1f80) - -#define _MM_ROUND_NEAREST (0x0000) -#define _MM_ROUND_DOWN (0x2000) -#define _MM_ROUND_UP (0x4000) -#define _MM_ROUND_TOWARD_ZERO (0x6000) -#define _MM_ROUND_MASK (0x6000) - -#define _MM_FLUSH_ZERO_MASK (0x8000) -#define _MM_FLUSH_ZERO_ON (0x8000) -#define _MM_FLUSH_ZERO_OFF (0x0000) +#define _MM_EXCEPT_INVALID (0x0001U) +#define _MM_EXCEPT_DENORM (0x0002U) +#define _MM_EXCEPT_DIV_ZERO (0x0004U) +#define _MM_EXCEPT_OVERFLOW (0x0008U) +#define _MM_EXCEPT_UNDERFLOW (0x0010U) +#define _MM_EXCEPT_INEXACT (0x0020U) +#define _MM_EXCEPT_MASK (0x003fU) + +#define _MM_MASK_INVALID (0x0080U) +#define _MM_MASK_DENORM (0x0100U) +#define _MM_MASK_DIV_ZERO (0x0200U) +#define _MM_MASK_OVERFLOW (0x0400U) +#define _MM_MASK_UNDERFLOW (0x0800U) +#define _MM_MASK_INEXACT (0x1000U) +#define _MM_MASK_MASK (0x1f80U) + +#define _MM_ROUND_NEAREST (0x0000U) +#define _MM_ROUND_DOWN (0x2000U) +#define _MM_ROUND_UP (0x4000U) +#define _MM_ROUND_TOWARD_ZERO (0x6000U) +#define _MM_ROUND_MASK (0x6000U) + +#define _MM_FLUSH_ZERO_MASK (0x8000U) +#define _MM_FLUSH_ZERO_ON (0x8000U) +#define _MM_FLUSH_ZERO_OFF (0x0000U) #define _MM_GET_EXCEPTION_MASK() (_mm_getcsr() & _MM_MASK_MASK) #define _MM_GET_EXCEPTION_STATE() (_mm_getcsr() & _MM_EXCEPT_MASK) Index: clang/test/Headers/warn-cleanup.c =================================================================== --- /dev/null +++ clang/test/Headers/warn-cleanup.c @@ -0,0 +1,43 @@ +// Fix sign conversion warnings found by fsanitize=implicit-integer-sign-change +// in intrinsic headers. +// Preprocess file to workaround no warnings in system headers. +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ffreestanding -E 2>&1 \ +// RUN: | %clang_cc1 -x c - -triple x86_64-pc-linux-gnu -ffreestanding -Wsign-conversion %s 2>&1 \ +// RUN: | FileCheck --allow-empty %s +// REQUIRES: x86-registered-target + +#include +#include + +void test() { + // CHECK-NOT: warning: + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_OFF); + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_MASK); + + _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_INVALID); + _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_DENORM); + _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_DIV_ZERO); + _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_OVERFLOW); + _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_UNDERFLOW); + _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_INEXACT); + _MM_SET_EXCEPTION_STATE(_MM_EXCEPT_MASK); + + _MM_SET_EXCEPTION_MASK(_MM_MASK_INVALID); + _MM_SET_EXCEPTION_MASK(_MM_MASK_DENORM); + _MM_SET_EXCEPTION_MASK(_MM_MASK_DIV_ZERO); + _MM_SET_EXCEPTION_MASK(_MM_MASK_OVERFLOW); + _MM_SET_EXCEPTION_MASK(_MM_MASK_UNDERFLOW); + _MM_SET_EXCEPTION_MASK(_MM_MASK_INEXACT); + _MM_SET_EXCEPTION_MASK(_MM_MASK_MASK); + + _MM_SET_ROUNDING_MODE(_MM_ROUND_NEAREST); + _MM_SET_ROUNDING_MODE(_MM_ROUND_DOWN); + _MM_SET_ROUNDING_MODE(_MM_ROUND_UP); + _MM_SET_ROUNDING_MODE(_MM_ROUND_TOWARD_ZERO); + _MM_SET_ROUNDING_MODE(_MM_ROUND_MASK); + + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_MASK); + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_OFF); +}