1 // RUN: %clang_cc1 -emit-llvm -o - %s -fpascal-strings -fwchar-type=short -fno-signed-wchar | FileCheck %s
2
3 #include <stddef.h>
4
5 extern void abort (void);
6
7 typedef unsigned short UInt16;
8
9 typedef UInt16 UniChar;
10
main(int argc,char * argv[])11 int main(int argc, char* argv[])
12 {
13
14 char st[] = "\pfoo"; // pascal string
15 UniChar wt[] = L"\pbar"; // pascal Unicode string
16 UniChar wt1[] = L"\p";
17 UniChar wt2[] = L"\pgorf";
18
19 if (st[0] != 3)
20 abort ();
21 if (wt[0] != 3)
22 abort ();
23 if (wt1[0] != 0)
24 abort ();
25 if (wt2[0] != 4)
26 abort ();
27
28 return 0;
29 }
30
31 // CHECK: [i16 3, i16 98, i16 97, i16 114, i16 0]
32 // CHECK: [i16 4, i16 103, i16 111, i16 114, i16 102, i16 0]
33
34
35 // PR8856 - -fshort-wchar makes wchar_t be unsigned.
36 // CHECK: @test2
37 // CHECK: store volatile i32 1, ptr %isUnsigned
test2(void)38 void test2(void) {
39 volatile int isUnsigned = (wchar_t)-1 > (wchar_t)0;
40 }
41