| 1 |
/* Contributed by Kris Van Hees <[email protected]> */ |
| 2 |
/* Expected errors for char16_t/char32_t string literals. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-require-effective-target wchar } */ |
| 5 |
/* { dg-options "-std=gnu99 -fshort-wchar" } */ |
| 6 |
|
| 7 |
#include <wchar.h> |
| 8 |
|
| 9 |
typedef __CHAR16_TYPE__ char16_t; |
| 10 |
typedef __CHAR32_TYPE__ char32_t; |
| 11 |
|
| 12 |
const char s_0[] = "ab"; |
| 13 |
const char s_1[] = u"ab"; /* { dg-error "from a string literal with type array of" } */ |
| 14 |
const char s_2[] = U"ab"; /* { dg-error "from a string literal with type array of" } */ |
| 15 |
const char s_3[] = L"ab"; /* { dg-error "from a string literal with type array of" } */ |
| 16 |
const char 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" } */ |
| 21 |
const char16_t s16_3[] = L"ab"; |
| 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-warning " is too long" } */ |
| 25 |
const char16_t s16_6[1] = u"ab"; /* { dg-warning " is too long" } */ |
| 26 |
const char16_t s16_7[2] = u"ab"; |
| 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" } */ |
| 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" } */ |
| 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-warning " is too long" } */ |
| 37 |
const char32_t s32_6[1] = U"ab"; /* { dg-warning " is too long" } */ |
| 38 |
const char32_t s32_7[2] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ |
| 39 |
const char32_t s32_8[3] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ |
| 40 |
const char32_t s32_9[4] = U"ab"; /* { dg-warning " is too long" "" { target "m32c-*-*" } } */ |
| 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"; |
| 44 |
const wchar_t sw_2[] = U"ab"; /* { dg-error "from a string literal with type array of" } */ |
| 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." } */ |