blob: 962b19d3dd08bf9d2cc5974b68a5d864020f8bc8 [file] [log] [blame]
Douglas Gregor53afad52011-07-29 01:08:54 +00001// 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 Smith762bb9d2011-10-13 22:29:44 +00003// RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CPP0X %s
Douglas Gregor53afad52011-07-29 01:08:54 +00004
5#include <stddef.h>
Seo Sanghyeonad6ebd62007-12-23 03:11:58 +00006
7int main() {
Eric Christopher736a9c22011-08-24 00:33:55 +00008 // 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 Sanghyeonad6ebd62007-12-23 03:11:58 +000010 char a[10] = "abc";
Chris Lattnerdbb1ecc2009-02-26 23:01:51 +000011
Nico Webera0f15b02010-10-06 04:57:26 +000012 // This should convert to utf8.
Eric Christopher736a9c22011-08-24 00:33:55 +000013 // 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 Webera0f15b02010-10-06 04:57:26 +000015 char b[10] = "\u1120\u0220\U00102030";
16
Eli Friedman64f45a22011-11-01 02:23:42 +000017 // 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 Gregor5cee1192011-07-27 05:40:30 +000019 const wchar_t *foo = L"AB";
Nico Webera0f15b02010-10-06 04:57:26 +000020
Eli Friedman64f45a22011-11-01 02:23:42 +000021 // 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 Gregor5cee1192011-07-27 05:40:30 +000023 const wchar_t *bar = L"\u1234\U0010F00B";
24
Eli Friedman64f45a22011-11-01 02:23:42 +000025 // 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 Topper2e4f44f2011-08-11 05:57:09 +000027 const wchar_t *baz = L"\u1234" "\U0010F00C";
28
Douglas Gregor53afad52011-07-29 01:08:54 +000029#if __cplusplus >= 201103L
Eli Friedman64f45a22011-11-01 02:23:42 +000030 // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 67, i32 68, i32 0], align 4
Douglas Gregor5cee1192011-07-27 05:40:30 +000031 const char32_t *c = U"CD";
32
Eli Friedman64f45a22011-11-01 02:23:42 +000033 // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110028, i32 0], align 4
Douglas Gregor5cee1192011-07-27 05:40:30 +000034 const char32_t *d = U"\u1235\U0010F00C";
35
Eli Friedman64f45a22011-11-01 02:23:42 +000036 // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 4661, i32 1110027, i32 0], align 4
Craig Topper2e4f44f2011-08-11 05:57:09 +000037 const char32_t *o = "\u1235" U"\U0010F00B";
38
Eli Friedman64f45a22011-11-01 02:23:42 +000039 // CHECK-CPP0X: private unnamed_addr constant [3 x i16] [i16 69, i16 70, i16 0], align 2
Douglas Gregor5cee1192011-07-27 05:40:30 +000040 const char16_t *e = u"EF";
41
42 // This should convert to utf16.
Eli Friedman64f45a22011-11-01 02:23:42 +000043 // CHECK-CPP0X: private unnamed_addr constant [5 x i16] [i16 4384, i16 544, i16 -9272, i16 -9168, i16 0], align 2
Douglas Gregor5cee1192011-07-27 05:40:30 +000044 const char16_t *f = u"\u1120\u0220\U00102030";
45
Craig Topper2e4f44f2011-08-11 05:57:09 +000046 // This should convert to utf16.
Eli Friedman64f45a22011-11-01 02:23:42 +000047 // CHECK-CPP0X: private unnamed_addr constant [5 x i16] [i16 4384, i16 800, i16 -9272, i16 -9168, i16 0], align 2
Craig Topper2e4f44f2011-08-11 05:57:09 +000048 const char16_t *p = u"\u1120\u0320" "\U00102030";
49
Douglas Gregor53afad52011-07-29 01:08:54 +000050 // CHECK-CPP0X: private unnamed_addr constant [4 x i8] c"def\00", align 1
Douglas Gregor5cee1192011-07-27 05:40:30 +000051 const char *g = u8"def";
Craig Topper2fa4e862011-08-11 04:06:15 +000052
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 Friedman64f45a22011-11-01 02:23:42 +000059 // CHECK-CPP0X: private unnamed_addr constant [3 x i16] [i16 71, i16 72, i16 0], align 2
Craig Topper2fa4e862011-08-11 04:06:15 +000060 const char16_t *j = uR"foo(GH)foo";
61
Eli Friedman64f45a22011-11-01 02:23:42 +000062 // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 73, i32 74, i32 0], align 4
Craig Topper2fa4e862011-08-11 04:06:15 +000063 const char32_t *k = UR"bar(IJ)bar";
64
Eli Friedman64f45a22011-11-01 02:23:42 +000065 // CHECK-CPP0X: private unnamed_addr constant [3 x i32] [i32 75, i32 76, i32 0], align 4
Craig Topper2fa4e862011-08-11 04:06:15 +000066 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
73def)";
74
Craig Topper2e4f44f2011-08-11 05:57:09 +000075 // CHECK-CPP0X: private unnamed_addr constant [11 x i8] c"abc\0Adefghi\00", align 1
76 const char *q = R"(abc
77def)" "ghi";
78
Richard Smith30cddae2012-11-28 07:29:00 +000079 // 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??=
83def)";
84
85
Douglas Gregor53afad52011-07-29 01:08:54 +000086#endif
Seo Sanghyeonad6ebd62007-12-23 03:11:58 +000087}