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