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