| 1 |
/* Test C23 UTF-8 characters. Test valid usages. */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-std=c23 -pedantic-errors" } */ |
| 4 |
|
| 5 |
unsigned char a = u8'a'; |
| 6 |
_Static_assert (u8'a' == 97); |
| 7 |
|
| 8 |
unsigned char b = u8'\0'; |
| 9 |
_Static_assert (u8'\0' == 0); |
| 10 |
|
| 11 |
unsigned char c = u8'\xff'; |
| 12 |
_Static_assert (u8'\xff' == 255); |
| 13 |
|
| 14 |
unsigned char d = u8'\377'; |
| 15 |
_Static_assert (u8'\377' == 255); |
| 16 |
|
| 17 |
_Static_assert (sizeof (u8'a') == 1); |
| 18 |
_Static_assert (sizeof (u8'\0') == 1); |
| 19 |
_Static_assert (sizeof (u8'\xff') == 1); |
| 20 |
_Static_assert (sizeof (u8'\377') == 1); |
| 21 |
|
| 22 |
_Static_assert (_Generic (u8'a', unsigned char: 1, default: 2) == 1); |
| 23 |
_Static_assert (_Generic (u8'\0', unsigned char: 1, default: 2) == 1); |
| 24 |
_Static_assert (_Generic (u8'\xff', unsigned char: 1, default: 2) == 1); |
| 25 |
_Static_assert (_Generic (u8'\377', unsigned char: 1, default: 2) == 1); |
| 26 |
|
| 27 |
#if u8'\0' - 1 < 0 |
| 28 |
#error "UTF-8 constants not unsigned in preprocessor" |
| 29 |
#endif |