diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-11-29 23:03:58 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-11-29 23:03:58 +0000 |
commit | 0a7062f2cbb01b348bbc09be21a577957a2c68c2 (patch) | |
tree | da1211fdccf654b2fa17208e855530084abf0ee3 | |
parent | 7cc4dc0a9d5d8c310ec72810c2e8090de5a8b5ff (diff) | |
download | compiler-rt-0a7062f2cbb01b348bbc09be21a577957a2c68c2.tar.gz compiler-rt-0a7062f2cbb01b348bbc09be21a577957a2c68c2.tar.bz2 compiler-rt-0a7062f2cbb01b348bbc09be21a577957a2c68c2.tar.xz |
ubsan: Disable __int128 tests if the host Clang does not support it. These
tests will still fail if compiler-rt was built with a compiler without __int128
support, but the host compiler has __int128 support.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168955 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/ubsan/lit_tests/Float/cast-overflow.cpp | 10 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/Integer/add-overflow.cpp | 9 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/Integer/div-zero.cpp | 10 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/Integer/sub-overflow.cpp | 9 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/Integer/uadd-overflow.cpp | 9 | ||||
-rw-r--r-- | lib/ubsan/lit_tests/Integer/usub-overflow.cpp | 9 |
6 files changed, 45 insertions, 11 deletions
diff --git a/lib/ubsan/lit_tests/Float/cast-overflow.cpp b/lib/ubsan/lit_tests/Float/cast-overflow.cpp index b9c5d38c..24b654a4 100644 --- a/lib/ubsan/lit_tests/Float/cast-overflow.cpp +++ b/lib/ubsan/lit_tests/Float/cast-overflow.cpp @@ -14,6 +14,7 @@ // This test assumes float and double are IEEE-754 single- and double-precision. #include <stdint.h> +#include <stdio.h> #include <string.h> float Inf; @@ -30,8 +31,10 @@ int main(int argc, char **argv) { float MaxFloatRepresentableAsUInt = 0xffffff00u; (unsigned int)MaxFloatRepresentableAsUInt; // ok +#ifdef __SIZEOF_INT128__ unsigned __int128 FloatMaxAsUInt128 = -((unsigned __int128)1 << 104); (void)(float)FloatMaxAsUInt128; // ok +#endif // Build a '+Inf'. char InfVal[] = { 0x00, 0x00, 0x80, 0x7f }; @@ -71,8 +74,13 @@ int main(int argc, char **argv) { // Integer -> floating point overflow. case '6': - // CHECK-6: fatal error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float' + // CHECK-6: {{fatal error: value 0xffffff00000000000000000000000001 is outside the range of representable values of type 'float'|__int128 not supported}} +#ifdef __SIZEOF_INT128__ return (float)(FloatMaxAsUInt128 + 1); +#else + puts("__int128 not supported"); + return 0; +#endif // FIXME: The backend cannot lower __fp16 operations on x86 yet. //case '7': // (__fp16)65504; // ok diff --git a/lib/ubsan/lit_tests/Integer/add-overflow.cpp b/lib/ubsan/lit_tests/Integer/add-overflow.cpp index 020ae767..179099ac 100644 --- a/lib/ubsan/lit_tests/Integer/add-overflow.cpp +++ b/lib/ubsan/lit_tests/Integer/add-overflow.cpp @@ -3,6 +3,7 @@ // RUN: %clang -DADD_I128 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=ADD_I128 #include <stdint.h> +#include <stdio.h> int main() { // These promote to 'int'. @@ -12,7 +13,7 @@ int main() { #ifdef ADD_I32 int32_t k = 0x12345678; k += 0x789abcde; - // CHECK-ADD_I32: add-overflow.cpp:14:5: fatal error: signed integer overflow: 305419896 + 2023406814 cannot be represented in type 'int32_t' (aka 'int') + // CHECK-ADD_I32: add-overflow.cpp:[[@LINE-1]]:5: fatal error: signed integer overflow: 305419896 + 2023406814 cannot be represented in type 'int32_t' (aka 'int') #endif #ifdef ADD_I64 @@ -21,7 +22,11 @@ int main() { #endif #ifdef ADD_I128 +# ifdef __SIZEOF_INT128__ (void)((__int128_t(1) << 126) + (__int128_t(1) << 126)); - // CHECK-ADD_I128: 0x40000000000000000000000000000000 + 0x40000000000000000000000000000000 cannot be represented in type '__int128' +# else + puts("__int128 not supported"); +# endif + // CHECK-ADD_I128: {{0x40000000000000000000000000000000 \+ 0x40000000000000000000000000000000 cannot be represented in type '__int128'|__int128 not supported}} #endif } diff --git a/lib/ubsan/lit_tests/Integer/div-zero.cpp b/lib/ubsan/lit_tests/Integer/div-zero.cpp index f024835f..b9aed512 100644 --- a/lib/ubsan/lit_tests/Integer/div-zero.cpp +++ b/lib/ubsan/lit_tests/Integer/div-zero.cpp @@ -1,9 +1,15 @@ // RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND=0 %s -o %t && %t 2>&1 | FileCheck %s // RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND=1U %s -o %t && %t 2>&1 | FileCheck %s // RUN: %clang -fsanitize=float-divide-by-zero -DDIVIDEND=1.5 %s -o %t && %t 2>&1 | FileCheck %s -// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND='__int128(123)' %s -o %t && %t 2>&1 | FileCheck %s +// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND='intmax(123)' %s -o %t && %t 2>&1 | FileCheck %s + +#ifdef __SIZEOF_INT128__ +typedef __int128 intmax; +#else +typedef long long intmax; +#endif int main() { - // CHECK: div-zero.cpp:8:12: fatal error: division by zero + // CHECK: div-zero.cpp:[[@LINE+1]]:12: fatal error: division by zero DIVIDEND / 0; } diff --git a/lib/ubsan/lit_tests/Integer/sub-overflow.cpp b/lib/ubsan/lit_tests/Integer/sub-overflow.cpp index ee431548..e432cb88 100644 --- a/lib/ubsan/lit_tests/Integer/sub-overflow.cpp +++ b/lib/ubsan/lit_tests/Integer/sub-overflow.cpp @@ -3,6 +3,7 @@ // RUN: %clang -DSUB_I128 -fsanitize=signed-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=SUB_I128 #include <stdint.h> +#include <stdio.h> int main() { // These promote to 'int'. @@ -11,7 +12,7 @@ int main() { #ifdef SUB_I32 (void)(int32_t(-2) - int32_t(0x7fffffff)); - // CHECK-SUB_I32: sub-overflow.cpp:13:22: fatal error: signed integer overflow: -2 - 2147483647 cannot be represented in type 'int' + // CHECK-SUB_I32: sub-overflow.cpp:[[@LINE-1]]:22: fatal error: signed integer overflow: -2 - 2147483647 cannot be represented in type 'int' #endif #ifdef SUB_I64 @@ -20,7 +21,11 @@ int main() { #endif #ifdef SUB_I128 +# ifdef __SIZEOF_INT128__ (void)(-(__int128_t(1) << 126) - (__int128_t(1) << 126) - 1); - // CHECK-SUB_I128: 0x80000000000000000000000000000000 - 1 cannot be represented in type '__int128' +# else + puts("__int128 not supported"); +# endif + // CHECK-SUB_I128: {{0x80000000000000000000000000000000 - 1 cannot be represented in type '__int128'|__int128 not supported}} #endif } diff --git a/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp b/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp index bd25bd72..e373596b 100644 --- a/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp +++ b/lib/ubsan/lit_tests/Integer/uadd-overflow.cpp @@ -3,6 +3,7 @@ // RUN: %clang -DADD_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=ADD_I128 #include <stdint.h> +#include <stdio.h> int main() { // These promote to 'int'. @@ -12,7 +13,7 @@ int main() { #ifdef ADD_I32 uint32_t k = 0x87654321; k += 0xedcba987; - // CHECK-ADD_I32: uadd-overflow.cpp:14:5: fatal error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'uint32_t' (aka 'unsigned int') + // CHECK-ADD_I32: uadd-overflow.cpp:[[@LINE-1]]:5: fatal error: unsigned integer overflow: 2271560481 + 3989547399 cannot be represented in type 'uint32_t' (aka 'unsigned int') #endif #ifdef ADD_I64 @@ -21,7 +22,11 @@ int main() { #endif #ifdef ADD_I128 +# ifdef __SIZEOF_INT128__ (void)((__uint128_t(1) << 127) + (__uint128_t(1) << 127)); - // CHECK-ADD_I128: 0x80000000000000000000000000000000 + 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128' +# else + puts("__int128 not supported"); +# endif + // CHECK-ADD_I128: {{0x80000000000000000000000000000000 \+ 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128'|__int128 not supported}} #endif } diff --git a/lib/ubsan/lit_tests/Integer/usub-overflow.cpp b/lib/ubsan/lit_tests/Integer/usub-overflow.cpp index e91810b4..c8d9babb 100644 --- a/lib/ubsan/lit_tests/Integer/usub-overflow.cpp +++ b/lib/ubsan/lit_tests/Integer/usub-overflow.cpp @@ -3,6 +3,7 @@ // RUN: %clang -DSUB_I128 -fsanitize=unsigned-integer-overflow %s -o %t && %t 2>&1 | FileCheck %s --check-prefix=SUB_I128 #include <stdint.h> +#include <stdio.h> int main() { // These promote to 'int'. @@ -11,7 +12,7 @@ int main() { #ifdef SUB_I32 (void)(uint32_t(1) - uint32_t(2)); - // CHECK-SUB_I32: usub-overflow.cpp:13:22: fatal error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int' + // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: fatal error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int' #endif #ifdef SUB_I64 @@ -20,7 +21,11 @@ int main() { #endif #ifdef SUB_I128 +# ifdef __SIZEOF_INT128__ (void)((__uint128_t(1) << 126) - (__uint128_t(1) << 127)); - // CHECK-SUB_I128: 0x40000000000000000000000000000000 - 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128' +# else + puts("__int128 not supported\n"); +# endif + // CHECK-SUB_I128: {{0x40000000000000000000000000000000 - 0x80000000000000000000000000000000 cannot be represented in type 'unsigned __int128'|__int128 not supported}} #endif } |