diff options
author | John McCall <rjmccall@apple.com> | 2010-07-13 06:26:23 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-07-13 06:26:23 +0000 |
commit | a15eb737e4ada9c07baf83380574b59ef11d5759 (patch) | |
tree | 829412dea0130936b380046b0c9c67592f39b78a /clang/test/SemaCXX/conversion.cpp | |
parent | aa8c97262a2f6de0096b5bf913d084c22261b248 (diff) | |
download | bcm5719-llvm-a15eb737e4ada9c07baf83380574b59ef11d5759.tar.gz bcm5719-llvm-a15eb737e4ada9c07baf83380574b59ef11d5759.zip |
Check in this -Wconversion C++ test case that's been sitting on my machine
for awhile.
llvm-svn: 108232
Diffstat (limited to 'clang/test/SemaCXX/conversion.cpp')
-rw-r--r-- | clang/test/SemaCXX/conversion.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/conversion.cpp b/clang/test/SemaCXX/conversion.cpp new file mode 100644 index 00000000000..f6489438070 --- /dev/null +++ b/clang/test/SemaCXX/conversion.cpp @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -verify %s + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long uint64_t; + +// <rdar://problem/7909130> +namespace test0 { + int32_t test1_positive(char *I, char *E) { + return (E - I); // expected-warning {{implicit conversion loses integer precision}} + } + + int32_t test1_negative(char *I, char *E) { + return static_cast<int32_t>(E - I); + } + + uint32_t test2_positive(uint64_t x) { + return x; // expected-warning {{implicit conversion loses integer precision}} + } + + uint32_t test2_negative(uint64_t x) { + return (uint32_t) x; + } +} + +namespace test1 { + uint64_t test1(int x, unsigned y) { + return sizeof(x == y); + } + + uint64_t test2(int x, unsigned y) { + return __alignof(x == y); + } + + void * const foo(); + bool test2(void *p) { + return p == foo(); + } +} |