blob: 014f6eb4fb03ef2b43ca9a233c1272a7097ee69c [file] [log] [blame]
Douglas Gregor5cee1192011-07-27 05:40:30 +00001// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2// Runs in c++0x mode so that wchar_t, char16_t, and char32_t are available.
Nico Weber59705ae2010-10-09 00:27:47 +00003
4int main() {
5 // CHECK: store i8 97
6 char a = 'a';
7
8 // Should pick second character.
9 // CHECK: store i8 98
10 char b = 'ab';
11
12 // CHECK: store i32 97
13 wchar_t wa = L'a';
14
15 // Should pick second character.
16 // CHECK: store i32 98
17 wchar_t wb = L'ab';
18
Douglas Gregor5cee1192011-07-27 05:40:30 +000019 // CHECK: store i16 97
20 char16_t ua = u'a';
21
22 // Should pick second character.
23 // CHECK: store i16 98
24 char16_t ub = u'ab';
25
26 // CHECK: store i32 97
27 char32_t Ua = U'a';
28
29 // Should pick second character.
30 // CHECK: store i32 98
31 char32_t Ub = U'ab';
32
Nico Weber59705ae2010-10-09 00:27:47 +000033 // Should pick last character and store its lowest byte.
34 // This does not match gcc, which takes the last character, converts it to
35 // utf8, and then picks the second-lowest byte of that (they probably store
36 // the utf8 in uint16_ts internally and take the lower byte of that).
37 // CHECK: store i8 48
38 char c = '\u1120\u0220\U00102030';
39
40 // CHECK: store i32 61451
41 wchar_t wc = L'\uF00B';
42
Douglas Gregor5cee1192011-07-27 05:40:30 +000043 // -4085 == 0xf00b
44 // CHECK: store i16 -4085
45 char16_t uc = u'\uF00B';
46
47 // CHECK: store i32 61451
48 char32_t Uc = U'\uF00B';
49
Nico Weber59705ae2010-10-09 00:27:47 +000050 // CHECK: store i32 1110027
51 wchar_t wd = L'\U0010F00B';
52
Douglas Gregor5cee1192011-07-27 05:40:30 +000053 // Should take lower word of the 4byte UNC sequence. This does not match
54 // gcc. I don't understand what gcc does (it looks like it converts to utf16,
55 // then takes the second (!) utf16 word, swaps the lower two nibbles, and
56 // stores that?).
57 // CHECK: store i16 -4085
58 char16_t ud = u'\U0010F00B'; // has utf16 encoding dbc8 dcb0
59
60 // CHECK: store i32 1110027
61 char32_t Ud = U'\U0010F00B';
62
Nico Weber59705ae2010-10-09 00:27:47 +000063 // Should pick second character.
64 // CHECK: store i32 1110027
65 wchar_t we = L'\u1234\U0010F00B';
Douglas Gregor5cee1192011-07-27 05:40:30 +000066
67 // Should pick second character.
68 // CHECK: store i16 -4085
69 char16_t ue = u'\u1234\U0010F00B';
70
71 // Should pick second character.
72 // CHECK: store i32 1110027
73 char32_t Ue = U'\u1234\U0010F00B';
74
Nico Weber59705ae2010-10-09 00:27:47 +000075}