blob: 5452392ea55ba3b5c37d6952b776bf8fefdc4572 [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>
Nico Weber59705ae2010-10-09 00:27:47 +00006
7int main() {
Douglas Gregor53afad52011-07-29 01:08:54 +00008 // CHECK-C: store i8 97
9 // CHECK-CPP0X: store i8 97
Nico Weber59705ae2010-10-09 00:27:47 +000010 char a = 'a';
11
Seth Cantrell7748cbc2012-01-18 12:27:10 +000012 // Should truncate value (equal to last character).
Douglas Gregor53afad52011-07-29 01:08:54 +000013 // CHECK-C: store i8 98
14 // CHECK-CPP0X: store i8 98
Nico Weber59705ae2010-10-09 00:27:47 +000015 char b = 'ab';
16
Seth Cantrell7748cbc2012-01-18 12:27:10 +000017 // Should get concatonated characters
18 // CHECK-C: store i32 24930
19 // CHECK-CPP0X: store i32 24930
20 int b1 = 'ab';
21
22 // Should get concatonated characters
23 // CHECK-C: store i32 808464432
24 // CHECK-CPP0X: store i32 808464432
25 int b2 = '0000';
26
27 // Should get truncated value (last four characters concatonated)
28 // CHECK-C: store i32 1919512167
29 // CHECK-CPP0X: store i32 1919512167
30 int b3 = 'somesillylongstring';
31
Douglas Gregor53afad52011-07-29 01:08:54 +000032 // CHECK-C: store i32 97
33 // CHECK-CPP0X: store i32 97
Nico Weber59705ae2010-10-09 00:27:47 +000034 wchar_t wa = L'a';
35
36 // Should pick second character.
Douglas Gregor53afad52011-07-29 01:08:54 +000037 // CHECK-C: store i32 98
38 // CHECK-CPP0X: store i32 98
Nico Weber59705ae2010-10-09 00:27:47 +000039 wchar_t wb = L'ab';
40
Douglas Gregor53afad52011-07-29 01:08:54 +000041#if __cplusplus >= 201103L
42 // CHECK-CPP0X: store i16 97
Douglas Gregor5cee1192011-07-27 05:40:30 +000043 char16_t ua = u'a';
44
Douglas Gregor53afad52011-07-29 01:08:54 +000045 // CHECK-CPP0X: store i32 97
Douglas Gregor5cee1192011-07-27 05:40:30 +000046 char32_t Ua = U'a';
47
Douglas Gregor53afad52011-07-29 01:08:54 +000048#endif
Douglas Gregor5cee1192011-07-27 05:40:30 +000049
Douglas Gregor53afad52011-07-29 01:08:54 +000050 // CHECK-C: store i32 61451
51 // CHECK-CPP0X: store i32 61451
Nico Weber59705ae2010-10-09 00:27:47 +000052 wchar_t wc = L'\uF00B';
53
Douglas Gregor53afad52011-07-29 01:08:54 +000054#if __cplusplus >= 201103L
Douglas Gregor5cee1192011-07-27 05:40:30 +000055 // -4085 == 0xf00b
Douglas Gregor53afad52011-07-29 01:08:54 +000056 // CHECK-CPP0X: store i16 -4085
Douglas Gregor5cee1192011-07-27 05:40:30 +000057 char16_t uc = u'\uF00B';
58
Douglas Gregor53afad52011-07-29 01:08:54 +000059 // CHECK-CPP0X: store i32 61451
Douglas Gregor5cee1192011-07-27 05:40:30 +000060 char32_t Uc = U'\uF00B';
Douglas Gregor53afad52011-07-29 01:08:54 +000061#endif
Douglas Gregor5cee1192011-07-27 05:40:30 +000062
Douglas Gregor53afad52011-07-29 01:08:54 +000063 // CHECK-C: store i32 1110027
64 // CHECK-CPP0X: store i32 1110027
Nico Weber59705ae2010-10-09 00:27:47 +000065 wchar_t wd = L'\U0010F00B';
66
Douglas Gregor53afad52011-07-29 01:08:54 +000067#if __cplusplus >= 201103L
Douglas Gregor53afad52011-07-29 01:08:54 +000068 // CHECK-CPP0X: store i32 1110027
Douglas Gregor5cee1192011-07-27 05:40:30 +000069 char32_t Ud = U'\U0010F00B';
Douglas Gregor53afad52011-07-29 01:08:54 +000070#endif
Douglas Gregor5cee1192011-07-27 05:40:30 +000071
Nico Weber59705ae2010-10-09 00:27:47 +000072 // Should pick second character.
Douglas Gregor53afad52011-07-29 01:08:54 +000073 // CHECK-C: store i32 1110027
74 // CHECK-CPP0X: store i32 1110027
Nico Weber59705ae2010-10-09 00:27:47 +000075 wchar_t we = L'\u1234\U0010F00B';
Nico Weber59705ae2010-10-09 00:27:47 +000076}