| 1 |
// Test initialization from UTF-8 literals when -fchar8_t is enabled. |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-std=c++17 -fchar8_t" } |
| 4 |
|
| 5 |
char c1 = 'x'; |
| 6 |
char c2 = u8'x'; |
| 7 |
char8_t c3 = 'x'; |
| 8 |
char8_t c4 = u8'x'; |
| 9 |
char8_t c5 = u'x'; |
| 10 |
|
| 11 |
const char *pc1 = "x"; |
| 12 |
const char *pc2 = u8"x"; // { dg-error "invalid conversion from .const char8_t.. to .const char.." "char8_t" } |
| 13 |
const char8_t *pc3 = "x"; // { dg-error "invalid conversion from .const char.. to .const char8_t.." "char8_t" } |
| 14 |
const char8_t *pc4 = u8"x"; |
| 15 |
const char8_t *pc5 = u"x"; // { dg-error "cannot convert .const char16_t.. to .const char8_t.. in initialization" "char8_t" } |
| 16 |
|
| 17 |
const char (&rca1)[2] = "x"; |
| 18 |
const char (&rca2)[2] = u8"x"; // { dg-error "invalid initialization of reference of type .const char ....... from expression of type .const char8_t ...." "char8_t" } |
| 19 |
const char8_t (&rca3)[2] = "x"; // { dg-error "invalid initialization of reference of type .const char8_t ....... from expression of type .const char ...." "char8_t" } |
| 20 |
const char8_t (&rca4)[2] = u8"x"; |
| 21 |
const char8_t (&rca5)[2] = u"x"; // { dg-error "invalid initialization of reference of type .const char8_t ....... from expression of type .const char16_t ...." "char8_t" } |
| 22 |
|
| 23 |
char ca1[] = "x"; |
| 24 |
char ca2[] = u8"x"; |
| 25 |
char8_t ca3[] = "x"; // { dg-error "from a string literal with type array of .char." "char8_t" } |
| 26 |
char8_t ca4[] = u8"x"; |
| 27 |
char8_t ca5[] = u"x"; // { dg-error "from a string literal with type array of .char16_t." "char8_t" } |
| 28 |
|
| 29 |
signed char sca1[] = "x"; |
| 30 |
signed char sca2[] = u8"x"; // { dg-error "from a string literal with type array of .char8_t." "char8_t" } |
| 31 |
|
| 32 |
unsigned char uca1[] = "x"; |
| 33 |
unsigned char uca2[] = u8"x"; |