Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s |
| 2 | // RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=C %s |
Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CPP0X %s |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 4 | |
| 5 | #include <stddef.h> |
Seo Sanghyeon | ad6ebd6 | 2007-12-23 03:11:58 +0000 | [diff] [blame] | 6 | |
| 7 | int main() { |
Eric Christopher | 736a9c2 | 2011-08-24 00:33:55 +0000 | [diff] [blame] | 8 | // CHECK-C: private unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1 |
| 9 | // CHECK-CPP0X: private unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1 |
Seo Sanghyeon | ad6ebd6 | 2007-12-23 03:11:58 +0000 | [diff] [blame] | 10 | char a[10] = "abc"; |
Chris Lattner | dbb1ecc | 2009-02-26 23:01:51 +0000 | [diff] [blame] | 11 | |
Nico Weber | a0f15b0 | 2010-10-06 04:57:26 +0000 | [diff] [blame] | 12 | // This should convert to utf8. |
Eric Christopher | 736a9c2 | 2011-08-24 00:33:55 +0000 | [diff] [blame] | 13 | // CHECK-C: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1 |
| 14 | // CHECK-CPP0X: private unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1 |
Nico Weber | a0f15b0 | 2010-10-06 04:57:26 +0000 | [diff] [blame] | 15 | char b[10] = "\u1120\u0220\U00102030"; |
| 16 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 17 | // CHECK-C: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4 |
| 18 | // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 65, i32 66, i32 0], align 4 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 19 | const wchar_t *foo = L"AB"; |
Nico Weber | a0f15b0 | 2010-10-06 04:57:26 +0000 | [diff] [blame] | 20 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 21 | // CHECK-C: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4 |
| 22 | // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110027, i32 0], align 4 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 23 | const wchar_t *bar = L"\u1234\U0010F00B"; |
| 24 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 25 | // CHECK-C: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4 |
| 26 | // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4660, i32 1110028, i32 0], align 4 |
Craig Topper | 2e4f44f | 2011-08-11 05:57:09 +0000 | [diff] [blame] | 27 | const wchar_t *baz = L"\u1234" "\U0010F00C"; |
| 28 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 29 | #if __cplusplus >= 201103L |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 30 | // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 67, i32 68, i32 0], align 4 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 31 | const char32_t *c = U"CD"; |
| 32 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 33 | // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110028, i32 0], align 4 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 34 | const char32_t *d = U"\u1235\U0010F00C"; |
| 35 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 36 | // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110027, i32 0], align 4 |
Craig Topper | 2e4f44f | 2011-08-11 05:57:09 +0000 | [diff] [blame] | 37 | const char32_t *o = "\u1235" U"\U0010F00B"; |
| 38 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 39 | // CHECK-CPP0X: private unnamed_addr constant [3 x i16] [i16 69, i16 70, i16 0], align 2 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 40 | const char16_t *e = u"EF"; |
| 41 | |
| 42 | // This should convert to utf16. |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 43 | // CHECK-CPP0X: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0], align 2 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 44 | const char16_t *f = u"\u1120\u0220\U00102030"; |
| 45 | |
Craig Topper | 2e4f44f | 2011-08-11 05:57:09 +0000 | [diff] [blame] | 46 | // This should convert to utf16. |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 47 | // CHECK-CPP0X: private unnamed_addr constant [5 x i16] [i16 4384, i16 800, i16 -9272, i16 -9168, i16 0], align 2 |
Craig Topper | 2e4f44f | 2011-08-11 05:57:09 +0000 | [diff] [blame] | 48 | const char16_t *p = u"\u1120\u0320" "\U00102030"; |
| 49 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 50 | // CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"def\00", align 1 |
Douglas Gregor | 5cee119 | 2011-07-27 05:40:30 +0000 | [diff] [blame] | 51 | const char *g = u8"def"; |
Craig Topper | 2fa4e86 | 2011-08-11 04:06:15 +0000 | [diff] [blame] | 52 | |
| 53 | // CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"ghi\00", align 1 |
| 54 | const char *h = R"foo(ghi)foo"; |
| 55 | |
| 56 | // CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"jkl\00", align 1 |
| 57 | const char *i = u8R"bar(jkl)bar"; |
| 58 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 59 | // CHECK-CPP0X: private unnamed_addr constant [3 x i16] [i16 71, i16 72, i16 0], align 2 |
Craig Topper | 2fa4e86 | 2011-08-11 04:06:15 +0000 | [diff] [blame] | 60 | const char16_t *j = uR"foo(GH)foo"; |
| 61 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 62 | // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 73, i32 74, i32 0], align 4 |
Craig Topper | 2fa4e86 | 2011-08-11 04:06:15 +0000 | [diff] [blame] | 63 | const char32_t *k = UR"bar(IJ)bar"; |
| 64 | |
Eli Friedman | 64f45a2 | 2011-11-01 02:23:42 +0000 | [diff] [blame] | 65 | // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 75, i32 76, i32 0], align 4 |
Craig Topper | 2fa4e86 | 2011-08-11 04:06:15 +0000 | [diff] [blame] | 66 | const wchar_t *l = LR"bar(KL)bar"; |
| 67 | |
| 68 | // CHECK-CPP0X: private unnamed_addr constant [9 x i8] c"abc\5Cndef\00", align 1 |
| 69 | const char *m = R"(abc\ndef)"; |
| 70 | |
| 71 | // CHECK-CPP0X: private unnamed_addr constant [8 x i8] c"abc\0Adef\00", align 1 |
| 72 | const char *n = R"(abc |
| 73 | def)"; |
| 74 | |
Craig Topper | 2e4f44f | 2011-08-11 05:57:09 +0000 | [diff] [blame] | 75 | // CHECK-CPP0X: private unnamed_addr constant [11 x i8] c"abc\0Adefghi\00", align 1 |
| 76 | const char *q = R"(abc |
| 77 | def)" "ghi"; |
| 78 | |
Richard Smith | 30cddae | 2012-11-28 07:29:00 +0000 | [diff] [blame] | 79 | // CHECK-CPP0X: private unnamed_addr constant [13 x i8] c"abc\5C\0A??=\0Adef\00", align 1 |
| 80 | const char *r = R\ |
| 81 | "(abc\ |
| 82 | ??= |
| 83 | def)"; |
| 84 | |
| 85 | |
Douglas Gregor | 53afad5 | 2011-07-29 01:08:54 +0000 | [diff] [blame] | 86 | #endif |
Seo Sanghyeon | ad6ebd6 | 2007-12-23 03:11:58 +0000 | [diff] [blame] | 87 | } |