xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/string-literal-short-wstring.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -x c++ -triple %itanium_abi_triple -emit-llvm -fshort-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=ITANIUM
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -x c++ -triple %ms_abi_triple -emit-llvm -fshort-wchar %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSABI
3f4a2713aSLionel Sambuc // Runs in c++ mode so that wchar_t is available.
4f4a2713aSLionel Sambuc 
main()5f4a2713aSLionel Sambuc int main() {
6f4a2713aSLionel Sambuc   // This should convert to utf8.
7f4a2713aSLionel Sambuc   // CHECK: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
8f4a2713aSLionel Sambuc   char b[10] = "\u1120\u0220\U00102030";
9f4a2713aSLionel Sambuc 
10*0a6a1f1dSLionel Sambuc   // ITANIUM: private unnamed_addr constant [3 x i16] [i16 65, i16 66, i16 0]
11*0a6a1f1dSLionel Sambuc   // MSABI: linkonce_odr unnamed_addr constant [3 x i16] [i16 65, i16 66, i16 0]
12f4a2713aSLionel Sambuc   const wchar_t *foo = L"AB";
13f4a2713aSLionel Sambuc 
14f4a2713aSLionel Sambuc   // This should convert to utf16.
15*0a6a1f1dSLionel Sambuc   // ITANIUM: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0]
16*0a6a1f1dSLionel Sambuc   // MSABI: linkonce_odr unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0]
17f4a2713aSLionel Sambuc   const wchar_t *bar = L"\u1120\u0220\U00102030";
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc 
21f4a2713aSLionel Sambuc   // Should pick second character.
22f4a2713aSLionel Sambuc   // CHECK: store i8 98
23f4a2713aSLionel Sambuc   char c = 'ab';
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc   // CHECK: store i16 97
26f4a2713aSLionel Sambuc   wchar_t wa = L'a';
27f4a2713aSLionel Sambuc 
28f4a2713aSLionel Sambuc   // Should pick second character.
29f4a2713aSLionel Sambuc   // CHECK: store i16 98
30f4a2713aSLionel Sambuc   wchar_t wb = L'ab';
31f4a2713aSLionel Sambuc 
32f4a2713aSLionel Sambuc   // -4085 == 0xf00b
33f4a2713aSLionel Sambuc   // CHECK: store i16 -4085
34f4a2713aSLionel Sambuc   wchar_t wc = L'\uF00B';
35f4a2713aSLionel Sambuc }
36