blob: 6fdf8b7c02b1c757c7671d94872147f03b243f8d [file] [log] [blame]
Tim Northover931a4fe2013-08-12 12:51:05 +00001// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-C %s
2// RUN: %clang_cc1 -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-C %s
3// RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CHECK-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 Cantrelle4248442012-01-21 00:16:11 +000017 // Should get concatenated characters
Seth Cantrell7748cbc2012-01-18 12:27:10 +000018 // CHECK-C: store i32 24930
19 // CHECK-CPP0X: store i32 24930
20 int b1 = 'ab';
21
Seth Cantrelle4248442012-01-21 00:16:11 +000022 // Should get concatenated characters
Seth Cantrell7748cbc2012-01-18 12:27:10 +000023 // CHECK-C: store i32 808464432
24 // CHECK-CPP0X: store i32 808464432
25 int b2 = '0000';
26
Seth Cantrelle4248442012-01-21 00:16:11 +000027 // Should get truncated value (last four characters concatenated)
Seth Cantrell7748cbc2012-01-18 12:27:10 +000028 // 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
Seth Cantrelle4248442012-01-21 00:16:11 +000048 // CHECK-CPP0X: store i16 1047
49 char16_t ua1 = u'З';
50 // CHECK-CPP0X: store i16 12538
51 char16_t ua2 = u'ヺ';
52 // CHECK-CPP0X: store i16 -27177
53 char16_t ua3 = u'闗';
54
55 // CHECK-CPP0X: store i32 181
56 char32_t Ua1 = U'µ';
57 // CHECK-CPP0X: store i32 38359
58 char32_t Ua2 = U'闗';
59 // CHECK-CPP0X: store i32 128128
60 char32_t Ua3 = U'💀';
61
Douglas Gregor53afad52011-07-29 01:08:54 +000062#endif
Douglas Gregor5cee1192011-07-27 05:40:30 +000063
Douglas Gregor53afad52011-07-29 01:08:54 +000064 // CHECK-C: store i32 61451
65 // CHECK-CPP0X: store i32 61451
Nico Weber59705ae2010-10-09 00:27:47 +000066 wchar_t wc = L'\uF00B';
67
Douglas Gregor53afad52011-07-29 01:08:54 +000068#if __cplusplus >= 201103L
Douglas Gregor5cee1192011-07-27 05:40:30 +000069 // -4085 == 0xf00b
Douglas Gregor53afad52011-07-29 01:08:54 +000070 // CHECK-CPP0X: store i16 -4085
Douglas Gregor5cee1192011-07-27 05:40:30 +000071 char16_t uc = u'\uF00B';
72
Douglas Gregor53afad52011-07-29 01:08:54 +000073 // CHECK-CPP0X: store i32 61451
Douglas Gregor5cee1192011-07-27 05:40:30 +000074 char32_t Uc = U'\uF00B';
Douglas Gregor53afad52011-07-29 01:08:54 +000075#endif
Douglas Gregor5cee1192011-07-27 05:40:30 +000076
Douglas Gregor53afad52011-07-29 01:08:54 +000077 // CHECK-C: store i32 1110027
78 // CHECK-CPP0X: store i32 1110027
Nico Weber59705ae2010-10-09 00:27:47 +000079 wchar_t wd = L'\U0010F00B';
80
Douglas Gregor53afad52011-07-29 01:08:54 +000081#if __cplusplus >= 201103L
Douglas Gregor53afad52011-07-29 01:08:54 +000082 // CHECK-CPP0X: store i32 1110027
Douglas Gregor5cee1192011-07-27 05:40:30 +000083 char32_t Ud = U'\U0010F00B';
Douglas Gregor53afad52011-07-29 01:08:54 +000084#endif
Douglas Gregor5cee1192011-07-27 05:40:30 +000085
Nico Weber59705ae2010-10-09 00:27:47 +000086 // Should pick second character.
Douglas Gregor53afad52011-07-29 01:08:54 +000087 // CHECK-C: store i32 1110027
88 // CHECK-CPP0X: store i32 1110027
Nico Weber59705ae2010-10-09 00:27:47 +000089 wchar_t we = L'\u1234\U0010F00B';
Nico Weber59705ae2010-10-09 00:27:47 +000090}