| 1 |
// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-C %s |
| 2 |
// RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-CPP0X %s |
| 3 |
|
| 4 |
#include <stddef.h> |
| 5 |
|
| 6 |
int main(void) { |
| 7 |
// CHECK-C: store i8 97 |
| 8 |
// CHECK-CPP0X: store i8 97 |
| 9 |
char a = 'a'; |
| 10 |
|
| 11 |
// Should truncate value (equal to last character). |
| 12 |
// CHECK-C: store i8 98 |
| 13 |
// CHECK-CPP0X: store i8 98 |
| 14 |
char b = 'ab'; |
| 15 |
|
| 16 |
// Should get concatenated characters |
| 17 |
// CHECK-C: store i32 24930 |
| 18 |
// CHECK-CPP0X: store i32 24930 |
| 19 |
int b1 = 'ab'; |
| 20 |
|
| 21 |
// Should get concatenated characters |
| 22 |
// CHECK-C: store i32 808464432 |
| 23 |
// CHECK-CPP0X: store i32 808464432 |
| 24 |
int b2 = '0000'; |
| 25 |
|
| 26 |
// Should get truncated value (last four characters concatenated) |
| 27 |
// CHECK-C: store i32 1919512167 |
| 28 |
// CHECK-CPP0X: store i32 1919512167 |
| 29 |
int b3 = 'somesillylongstring'; |
| 30 |
|
| 31 |
// CHECK-C: store i32 97 |
| 32 |
// CHECK-CPP0X: store i32 97 |
| 33 |
wchar_t wa = L'a'; |
| 34 |
|
| 35 |
#if __cplusplus >= 201103L |
| 36 |
// CHECK-CPP0X: store i16 97 |
| 37 |
char16_t ua = u'a'; |
| 38 |
|
| 39 |
// CHECK-CPP0X: store i32 97 |
| 40 |
char32_t Ua = U'a'; |
| 41 |
|
| 42 |
// CHECK-CPP0X: store i16 1047 |
| 43 |
char16_t ua1 = u'З'; |
| 44 |
// CHECK-CPP0X: store i16 12538 |
| 45 |
char16_t ua2 = u'ヺ'; |
| 46 |
// CHECK-CPP0X: store i16 -27177 |
| 47 |
char16_t ua3 = u'闗'; |
| 48 |
|
| 49 |
// CHECK-CPP0X: store i32 181 |
| 50 |
char32_t Ua1 = U'µ'; |
| 51 |
// CHECK-CPP0X: store i32 38359 |
| 52 |
char32_t Ua2 = U'闗'; |
| 53 |
// CHECK-CPP0X: store i32 128128 |
| 54 |
char32_t Ua3 = U'💀'; |
| 55 |
|
| 56 |
#endif |
| 57 |
|
| 58 |
// CHECK-C: store i32 61451 |
| 59 |
// CHECK-CPP0X: store i32 61451 |
| 60 |
wchar_t wc = L'\uF00B'; |
| 61 |
|
| 62 |
#if __cplusplus >= 201103L |
| 63 |
// -4085 == 0xf00b |
| 64 |
// CHECK-CPP0X: store i16 -4085 |
| 65 |
char16_t uc = u'\uF00B'; |
| 66 |
|
| 67 |
// CHECK-CPP0X: store i32 61451 |
| 68 |
char32_t Uc = U'\uF00B'; |
| 69 |
#endif |
| 70 |
|
| 71 |
// CHECK-C: store i32 1110027 |
| 72 |
// CHECK-CPP0X: store i32 1110027 |
| 73 |
wchar_t wd = L'\U0010F00B'; |
| 74 |
|
| 75 |
#if __cplusplus >= 201103L |
| 76 |
// CHECK-CPP0X: store i32 1110027 |
| 77 |
char32_t Ud = U'\U0010F00B'; |
| 78 |
#endif |
| 79 |
|
| 80 |
} |