]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/c2x-utf8char-1.c
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / c2x-utf8char-1.c
CommitLineData
7c5890cc
JM
1/* Test C2x UTF-8 characters. Test valid usages. */
2/* { dg-do compile } */
3/* { dg-options "-std=c2x -pedantic-errors" } */
4
5unsigned char a = u8'a';
6_Static_assert (u8'a' == 97);
7
8unsigned char b = u8'\0';
9_Static_assert (u8'\0' == 0);
10
11unsigned char c = u8'\xff';
12_Static_assert (u8'\xff' == 255);
13
14unsigned 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