1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-C %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-C %s
3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-CXX11 %s
4*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -x c -std=c11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-C11 %s
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc #include <stddef.h>
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc #ifndef __cplusplus
9*f4a2713aSLionel Sambuc typedef __WCHAR_TYPE__ wchar_t;
10*f4a2713aSLionel Sambuc typedef __CHAR16_TYPE__ char16_t;
11*f4a2713aSLionel Sambuc typedef __CHAR32_TYPE__ char32_t;
12*f4a2713aSLionel Sambuc #endif
13*f4a2713aSLionel Sambuc
main()14*f4a2713aSLionel Sambuc int main() {
15*f4a2713aSLionel Sambuc // CHECK-C: private unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
16*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
17*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
18*f4a2713aSLionel Sambuc char a[10] = "abc";
19*f4a2713aSLionel Sambuc
20*f4a2713aSLionel Sambuc // This should convert to utf8.
21*f4a2713aSLionel Sambuc // CHECK-C: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
22*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
23*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
24*f4a2713aSLionel Sambuc char b[10] = "\u1120\u0220\U00102030";
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambuc // CHECK-C: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4
27*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4
28*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4
29*f4a2713aSLionel Sambuc const wchar_t *foo = L"AB";
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc // CHECK-C: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4
32*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4
33*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4
34*f4a2713aSLionel Sambuc const wchar_t *bar = L"\u1234\U0010F00B";
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc // CHECK-C: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4
37*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4
38*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4
39*f4a2713aSLionel Sambuc const wchar_t *baz = L"\u1234" "\U0010F00C";
40*f4a2713aSLionel Sambuc
41*f4a2713aSLionel Sambuc #if __cplusplus >= 201103L || __STDC_VERSION__ >= 201112L
42*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [3 x i32] [i32 67, i32 68, i32 0], align 4
43*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i32] [i32 67, i32 68, i32 0], align 4
44*f4a2713aSLionel Sambuc const char32_t *c = U"CD";
45*f4a2713aSLionel Sambuc
46*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110028, i32 0], align 4
47*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110028, i32 0], align 4
48*f4a2713aSLionel Sambuc const char32_t *d = U"\u1235\U0010F00C";
49*f4a2713aSLionel Sambuc
50*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110027, i32 0], align 4
51*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110027, i32 0], align 4
52*f4a2713aSLionel Sambuc const char32_t *o = "\u1235" U"\U0010F00B";
53*f4a2713aSLionel Sambuc
54*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [3 x i16] [i16 69, i16 70, i16 0], align 2
55*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i16] [i16 69, i16 70, i16 0], align 2
56*f4a2713aSLionel Sambuc const char16_t *e = u"EF";
57*f4a2713aSLionel Sambuc
58*f4a2713aSLionel Sambuc // This should convert to utf16.
59*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0], align 2
60*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0], align 2
61*f4a2713aSLionel Sambuc const char16_t *f = u"\u1120\u0220\U00102030";
62*f4a2713aSLionel Sambuc
63*f4a2713aSLionel Sambuc // This should convert to utf16.
64*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [5 x i16] [i16 4384, i16 800, i16 -9272, i16 -9168, i16 0], align 2
65*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [5 x i16] [i16 4384, i16 800, i16 -9272, i16 -9168, i16 0], align 2
66*f4a2713aSLionel Sambuc const char16_t *p = u"\u1120\u0320" "\U00102030";
67*f4a2713aSLionel Sambuc
68*f4a2713aSLionel Sambuc // CHECK-C11: private unnamed_addr constant [4 x i8] c"def\00", align 1
69*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [4 x i8] c"def\00", align 1
70*f4a2713aSLionel Sambuc const char *g = u8"def";
71*f4a2713aSLionel Sambuc
72*f4a2713aSLionel Sambuc #ifdef __cplusplus
73*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [4 x i8] c"ghi\00", align 1
74*f4a2713aSLionel Sambuc const char *h = R"foo(ghi)foo";
75*f4a2713aSLionel Sambuc
76*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [4 x i8] c"jkl\00", align 1
77*f4a2713aSLionel Sambuc const char *i = u8R"bar(jkl)bar";
78*f4a2713aSLionel Sambuc
79*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i16] [i16 71, i16 72, i16 0], align 2
80*f4a2713aSLionel Sambuc const char16_t *j = uR"foo(GH)foo";
81*f4a2713aSLionel Sambuc
82*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i32] [i32 73, i32 74, i32 0], align 4
83*f4a2713aSLionel Sambuc const char32_t *k = UR"bar(IJ)bar";
84*f4a2713aSLionel Sambuc
85*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [3 x i32] [i32 75, i32 76, i32 0], align 4
86*f4a2713aSLionel Sambuc const wchar_t *l = LR"bar(KL)bar";
87*f4a2713aSLionel Sambuc
88*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [9 x i8] c"abc\5Cndef\00", align 1
89*f4a2713aSLionel Sambuc const char *m = R"(abc\ndef)";
90*f4a2713aSLionel Sambuc
91*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [8 x i8] c"abc\0Adef\00", align 1
92*f4a2713aSLionel Sambuc const char *n = R"(abc
93*f4a2713aSLionel Sambuc def)";
94*f4a2713aSLionel Sambuc
95*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [11 x i8] c"abc\0Adefghi\00", align 1
96*f4a2713aSLionel Sambuc const char *q = R"(abc
97*f4a2713aSLionel Sambuc def)" "ghi";
98*f4a2713aSLionel Sambuc
99*f4a2713aSLionel Sambuc // CHECK-CXX11: private unnamed_addr constant [13 x i8] c"abc\5C\0A??=\0Adef\00", align 1
100*f4a2713aSLionel Sambuc const char *r = R\
101*f4a2713aSLionel Sambuc "(abc\
102*f4a2713aSLionel Sambuc ??=
103*f4a2713aSLionel Sambuc def)";
104*f4a2713aSLionel Sambuc
105*f4a2713aSLionel Sambuc #endif
106*f4a2713aSLionel Sambuc #endif
107*f4a2713aSLionel Sambuc }
108