1 /* Contributed by Kris Van Hees <kris.van.hees@oracle.com> */ 2 /* Expected errors for char16_t/char32_t string literals. */ 3 /* { dg-do compile { target c++11 } } */ 4 // { dg-options "" } 5 6 #if __cpp_char8_t 7 typedef char8_t u8_char_t; 8 #else 9 typedef char u8_char_t; 10 #endif 11 12 const char s_0[] = "ab"; 13 const char s_1[] = u"ab"; /* { dg-error "from a string literal with type array of .char16_t." } */ 14 const char s_2[] = U"ab"; /* { dg-error "from a string literal with type array of .char32_t." } */ 15 const char s_3[] = L"ab"; /* { dg-error "from a string literal with type array of .wchar_t." } */ 16 const u8_char_t s_4[] = u8"ab"; 17 18 const char16_t s16_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ 19 const char16_t s16_1[] = u"ab"; 20 const char16_t s16_2[] = U"ab"; /* { dg-error "from a string literal with type array of .char32_t." } */ 21 const char16_t s16_3[] = L"ab"; /* { dg-error "from a string literal with type array of .wchar_t." } */ 22 const char16_t s16_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ 23 24 const char16_t s16_5[0] = u"ab"; /* { dg-error "initializer-string for 'const char16_t \\\[0]' is too long" } */ 25 const char16_t s16_6[1] = u"ab"; /* { dg-error "initializer-string for 'const char16_t \\\[1]' is too long" } */ 26 const char16_t s16_7[2] = u"ab"; /* { dg-error "initializer-string for 'const char16_t \\\[2]' is too long" } */ 27 const char16_t s16_8[3] = u"ab"; 28 const char16_t s16_9[4] = u"ab"; 29 30 const char32_t s32_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ 31 const char32_t s32_1[] = u"ab"; /* { dg-error "from a string literal with type array of .char16_t." } */ 32 const char32_t s32_2[] = U"ab"; 33 const char32_t s32_3[] = L"ab"; /* { dg-error "from a string literal with type array of .wchar_t." } */ 34 const char32_t s32_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ 35 36 const char32_t s32_5[0] = U"ab"; /* { dg-error "initializer-string for 'const char32_t \\\[0]' is too long" } */ 37 const char32_t s32_6[1] = U"ab"; /* { dg-error "initializer-string for 'const char32_t \\\[1]' is too long" } */ 38 const char32_t s32_7[2] = U"ab"; /* { dg-error "initializer-string for 'const char32_t \\\[2]' is too long" } */ 39 const char32_t s32_8[3] = U"ab"; 40 const char32_t s32_9[4] = U"ab"; 41 42 const wchar_t sw_0[] = "ab"; /* { dg-error "from a string literal with type array of .char." } */ 43 const wchar_t sw_1[] = u"ab"; /* { dg-error "from a string literal with type array of .char16_t." } */ 44 const wchar_t sw_2[] = U"ab"; /* { dg-error "from a string literal with type array of .char32_t." } */ 45 const wchar_t sw_3[] = L"ab"; 46 const wchar_t sw_4[] = u8"ab"; /* { dg-error "from a string literal with type array of .char." } */ 47