Home | History | Annotate | Download | only in CodeGen
      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
      3 // RUN: %clang_cc1 -x c++ -std=c++11 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck -check-prefix=CPP0X %s
      4 
      5 #include <stddef.h>
      6 
      7 int main() {
      8   // CHECK-C: store i8 97
      9   // CHECK-CPP0X: store i8 97
     10   char a = 'a';
     11 
     12   // Should truncate value (equal to last character).
     13   // CHECK-C: store i8 98
     14   // CHECK-CPP0X: store i8 98
     15   char b = 'ab';
     16 
     17   // Should get concatenated characters
     18   // CHECK-C: store i32 24930
     19   // CHECK-CPP0X: store i32 24930
     20   int b1 = 'ab';
     21 
     22   // Should get concatenated 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 concatenated)
     28   // CHECK-C: store i32 1919512167
     29   // CHECK-CPP0X: store i32 1919512167
     30   int b3 = 'somesillylongstring';
     31 
     32   // CHECK-C: store i32 97
     33   // CHECK-CPP0X: store i32 97
     34   wchar_t wa = L'a';
     35 
     36   // Should pick second character.
     37   // CHECK-C: store i32 98
     38   // CHECK-CPP0X: store i32 98
     39   wchar_t wb = L'ab';
     40 
     41 #if __cplusplus >= 201103L
     42   // CHECK-CPP0X: store i16 97
     43   char16_t ua = u'a';
     44 
     45   // CHECK-CPP0X: store i32 97
     46   char32_t Ua = U'a';
     47 
     48   // 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 
     62 #endif
     63 
     64   // CHECK-C: store i32 61451
     65   // CHECK-CPP0X: store i32 61451
     66   wchar_t wc = L'\uF00B';
     67 
     68 #if __cplusplus >= 201103L
     69   // -4085 == 0xf00b
     70   // CHECK-CPP0X: store i16 -4085
     71   char16_t uc = u'\uF00B';
     72 
     73   // CHECK-CPP0X: store i32 61451
     74   char32_t Uc = U'\uF00B';
     75 #endif
     76 
     77   // CHECK-C: store i32 1110027
     78   // CHECK-CPP0X: store i32 1110027
     79   wchar_t wd = L'\U0010F00B';
     80 
     81 #if __cplusplus >= 201103L
     82   // CHECK-CPP0X: store i32 1110027
     83   char32_t Ud = U'\U0010F00B';
     84 #endif
     85 
     86   // Should pick second character.
     87   // CHECK-C: store i32 1110027
     88   // CHECK-CPP0X: store i32 1110027
     89   wchar_t we = L'\u1234\U0010F00B';
     90 }
     91