summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CodeGen')
-rw-r--r--clang/test/CodeGen/char-literal.c44
-rw-r--r--clang/test/CodeGen/string-literal.c23
2 files changed, 62 insertions, 5 deletions
diff --git a/clang/test/CodeGen/char-literal.c b/clang/test/CodeGen/char-literal.c
index 322041c0049..014f6eb4fb0 100644
--- a/clang/test/CodeGen/char-literal.c
+++ b/clang/test/CodeGen/char-literal.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
-// Runs in c++ mode so that wchar_t is available.
+// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// Runs in c++0x mode so that wchar_t, char16_t, and char32_t are available.
int main() {
// CHECK: store i8 97
@@ -16,6 +16,20 @@ int main() {
// CHECK: store i32 98
wchar_t wb = L'ab';
+ // CHECK: store i16 97
+ char16_t ua = u'a';
+
+ // Should pick second character.
+ // CHECK: store i16 98
+ char16_t ub = u'ab';
+
+ // CHECK: store i32 97
+ char32_t Ua = U'a';
+
+ // Should pick second character.
+ // CHECK: store i32 98
+ char32_t Ub = U'ab';
+
// Should pick last character and store its lowest byte.
// This does not match gcc, which takes the last character, converts it to
// utf8, and then picks the second-lowest byte of that (they probably store
@@ -26,10 +40,36 @@ int main() {
// CHECK: store i32 61451
wchar_t wc = L'\uF00B';
+ // -4085 == 0xf00b
+ // CHECK: store i16 -4085
+ char16_t uc = u'\uF00B';
+
+ // CHECK: store i32 61451
+ char32_t Uc = U'\uF00B';
+
// CHECK: store i32 1110027
wchar_t wd = L'\U0010F00B';
+ // Should take lower word of the 4byte UNC sequence. This does not match
+ // gcc. I don't understand what gcc does (it looks like it converts to utf16,
+ // then takes the second (!) utf16 word, swaps the lower two nibbles, and
+ // stores that?).
+ // CHECK: store i16 -4085
+ char16_t ud = u'\U0010F00B'; // has utf16 encoding dbc8 dcb0
+
+ // CHECK: store i32 1110027
+ char32_t Ud = U'\U0010F00B';
+
// Should pick second character.
// CHECK: store i32 1110027
wchar_t we = L'\u1234\U0010F00B';
+
+ // Should pick second character.
+ // CHECK: store i16 -4085
+ char16_t ue = u'\u1234\U0010F00B';
+
+ // Should pick second character.
+ // CHECK: store i32 1110027
+ char32_t Ue = U'\u1234\U0010F00B';
+
}
diff --git a/clang/test/CodeGen/string-literal.c b/clang/test/CodeGen/string-literal.c
index cc6c0943d95..6d14330a0b9 100644
--- a/clang/test/CodeGen/string-literal.c
+++ b/clang/test/CodeGen/string-literal.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++0x -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// Runs in c++0x mode so that wchar_t, char16_t, and char32_t are available.
int main() {
// CHECK: internal unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
@@ -9,8 +10,24 @@ int main() {
char b[10] = "\u1120\u0220\U00102030";
// CHECK: private unnamed_addr constant [12 x i8] c"A\00\00\00B\00\00\00\00\00\00\00", align 1
- void *foo = L"AB";
+ const wchar_t *foo = L"AB";
// CHECK: private unnamed_addr constant [12 x i8] c"4\12\00\00\0B\F0\10\00\00\00\00\00", align 1
- void *bar = L"\u1234\U0010F00B";
+ const wchar_t *bar = L"\u1234\U0010F00B";
+
+ // CHECK: private unnamed_addr constant [12 x i8] c"C\00\00\00D\00\00\00\00\00\00\00", align 1
+ const char32_t *c = U"CD";
+
+ // CHECK: private unnamed_addr constant [12 x i8] c"5\12\00\00\0C\F0\10\00\00\00\00\00", align 1
+ const char32_t *d = U"\u1235\U0010F00C";
+
+ // CHECK: private unnamed_addr constant [6 x i8] c"E\00F\00\00\00", align 1
+ const char16_t *e = u"EF";
+
+ // This should convert to utf16.
+ // CHECK: private unnamed_addr constant [10 x i8] c" \11 \02\C8\DB0\DC\00\00", align 1
+ const char16_t *f = u"\u1120\u0220\U00102030";
+
+ // CHECK: private unnamed_addr constant [4 x i8] c"def\00", align 1
+ const char *g = u8"def";
}
OpenPOWER on IntegriCloud