Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s |
| 2 | // RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s |
Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CPP0X %s |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 4 | |
| 5 | #include <stddef.h> |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 6 | |
| 7 | int main() { |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 8 | // CHECK-C: store i8 97 |
| 9 | // CHECK-CPP0X: store i8 97 |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 10 | char a = 'a'; |
| 11 | |
Seth Cantrell | 7748cbc | 2012-01-18 12:27:10 +0000 | [diff] [blame] | 12 | // Should truncate value (equal to last character). |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 13 | // CHECK-C: store i8 98 |
| 14 | // CHECK-CPP0X: store i8 98 |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 15 | char b = 'ab'; |
| 16 | |
Seth Cantrell | 7748cbc | 2012-01-18 12:27:10 +0000 | [diff] [blame] | 17 | // Should get concatonated characters |
| 18 | // CHECK-C: store i32 24930 |
| 19 | // CHECK-CPP0X: store i32 24930 |
| 20 | int b1 = 'ab'; |
| 21 | |
| 22 | // Should get concatonated characters |
| 23 | // CHECK-C: store i32 808464432 |
| 24 | // CHECK-CPP0X: store i32 808464432 |
| 25 | int b2 = '0000'; |
| 26 | |
| 27 | // Should get truncated value (last four characters concatonated) |
| 28 | // CHECK-C: store i32 1919512167 |
| 29 | // CHECK-CPP0X: store i32 1919512167 |
| 30 | int b3 = 'somesillylongstring'; |
| 31 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 32 | // CHECK-C: store i32 97 |
| 33 | // CHECK-CPP0X: store i32 97 |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 34 | wchar_t wa = L'a'; |
| 35 | |
| 36 | // Should pick second character. |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 37 | // CHECK-C: store i32 98 |
| 38 | // CHECK-CPP0X: store i32 98 |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 39 | wchar_t wb = L'ab'; |
| 40 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 41 | #if __cplusplus >= 201103L |
| 42 | // CHECK-CPP0X: store i16 97 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 43 | char16_t ua = u'a'; |
| 44 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 45 | // CHECK-CPP0X: store i32 97 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 46 | char32_t Ua = U'a'; |
| 47 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 48 | #endif |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 49 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 50 | // CHECK-C: store i32 61451 |
| 51 | // CHECK-CPP0X: store i32 61451 |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 52 | wchar_t wc = L'\uF00B'; |
| 53 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 54 | #if __cplusplus >= 201103L |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 55 | // -4085 == 0xf00b |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 56 | // CHECK-CPP0X: store i16 -4085 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 57 | char16_t uc = u'\uF00B'; |
| 58 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 59 | // CHECK-CPP0X: store i32 61451 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 60 | char32_t Uc = U'\uF00B'; |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 61 | #endif |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 62 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 63 | // CHECK-C: store i32 1110027 |
| 64 | // CHECK-CPP0X: store i32 1110027 |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 65 | wchar_t wd = L'\U0010F00B'; |
| 66 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 67 | #if __cplusplus >= 201103L |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 68 | // CHECK-CPP0X: store i32 1110027 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 69 | char32_t Ud = U'\U0010F00B'; |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 70 | #endif |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 71 | |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 72 | // Should pick second character. |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 73 | // CHECK-C: store i32 1110027 |
| 74 | // CHECK-CPP0X: store i32 1110027 |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 75 | wchar_t we = L'\u1234\U0010F00B'; |
Nico Weber | 59705ae | 2010-10-09 00:27:47 +0000 | [diff] [blame] | 76 | } |