1 /* Test C2x UTF-8 characters. Test valid usages. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c2x -pedantic-errors" } */
5 unsigned char a
= u8
'a';
6 _Static_assert (u8
'a' == 97);
8 unsigned char b
= u8
'\0';
9 _Static_assert (u8
'\0' == 0);
11 unsigned char c
= u8
'\xff';
12 _Static_assert (u8
'\xff' == 255);
14 unsigned char d
= u8
'\377';
15 _Static_assert (u8
'\377' == 255);
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);
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);
28 #error "UTF-8 constants not unsigned in preprocessor"