Debian Codegraph @

gcc/testsuite/c-c++-common/cpp/delimited-escape-seq-1.c

raw
1 /* P2290R3 - Delimited escape sequences */
2 /* { dg-do run } */
3 /* { dg-require-effective-target wchar } */
4 /* { dg-options "-std=gnu99 -Wno-c++-compat" { target c } } */
5 /* { dg-options "-std=c++23" { target c++ } } */
6
7 #ifndef __cplusplus
8 #include <wchar.h>
9 typedef __CHAR16_TYPE__ char16_t;
10 typedef __CHAR32_TYPE__ char32_t;
11 #endif
12
13 const char32_t *a = U"\u{1234}\u{10fffd}\u{000000000000000000000000000000000000000000000000000000000001234}\u{10FFFD}";
14 const char32_t *b = U"\x{1234}\x{10fffd}\x{000000000000000000000000000000000000000000000000000000000001234}";
15 const char32_t *c = U"\o{1234}\o{4177775}\o{000000000000000000000000000000000000000000000000000000000000000000000000004177775}";
16 const char16_t *d = u"\u{1234}\u{bFFd}\u{00000000000000000000000000000001234}";
17 const char16_t *e = u"\x{1234}\x{BffD}\x{000001234}";
18 const char16_t *f = u"\o{1234}\o{137775}\o{000000000000000137775}";
19 const wchar_t *g = L"\u{1234}\u{bFFd}\u{00000000000000000000000000000001234}";
20 const wchar_t *h = L"\x{1234}\x{bFFd}\x{000001234}";
21 const wchar_t *i = L"\o{1234}\o{137775}\o{000000000000000137775}";
22 #ifdef __cplusplus
23 const char *j = "\u{34}\u{000000000000000003D}";
24 #endif
25 const char *k = "\x{34}\x{000000000000000003D}";
26 const char *l = "\o{34}\o{000000000000000176}";
27
28 #if U'\u{1234}' != U'\u1234' || U'\u{10fffd}' != U'\U0010FFFD' \
29 || U'\x{00000001234}' != U'\x1234' || U'\x{010fffd}' != U'\x10FFFD' \
30 || U'\o{1234}' != U'\x29c' || U'\o{004177775}' != U'\x10FFFD' \
31 || u'\u{1234}' != u'\u1234' || u'\u{0bffd}' != u'\uBFFD' \
32 || u'\x{00000001234}' != u'\x1234' || u'\x{0Bffd}' != u'\x0bFFD' \
33 || u'\o{1234}' != u'\x29c' || u'\o{00137775}' != u'\xBFFD' \
34 || L'\u{1234}' != L'\u1234' || L'\u{0bffd}' != L'\uBFFD' \
35 || L'\x{00000001234}' != L'\x1234' || L'\x{0bffd}' != L'\x0bFFD' \
36 || L'\o{1234}' != L'\x29c' || L'\o{00137775}' != L'\xBFFD' \
37 || '\x{34}' != '\x034' || '\x{0003d}' != '\x003D' \
38 || '\o{34}' != '\x1C' || '\o{176}' != '\x007E'
39 #error Bad
40 #endif
41 #ifdef __cplusplus
42 #if '\u{0000000034}' != '\u0034' || '\u{3d}' != '\u003D'
43 #error Bad
44 #endif
45 #endif
46
47 int
48 main ()
49 {
50 if (a[0] != U'\u1234' || a[0] != U'\u{1234}'
51 || a[1] != U'\U0010FFFD' || a[1] != U'\u{000010fFfD}'
52 || a[2] != a[0]
53 || a[3] != a[1]
54 || b[0] != U'\x1234' || b[0] != U'\x{001234}'
55 || b[1] != U'\x10FFFD' || b[1] != U'\x{0010fFfD}'
56 || b[2] != b[0]
57 || c[0] != U'\x29c' || c[0] != U'\o{001234}'
58 || c[1] != U'\x10FFFD' || c[1] != U'\o{4177775}'
59 || c[2] != c[1])
60 __builtin_abort ();
61 if (d[0] != u'\u1234' || d[0] != u'\u{1234}'
62 || d[1] != u'\U0000BFFD' || d[1] != u'\u{00000bFfD}'
63 || d[2] != d[0]
64 || e[0] != u'\x1234' || e[0] != u'\x{001234}'
65 || e[1] != u'\xBFFD' || e[1] != u'\x{00bFfD}'
66 || e[2] != e[0]
67 || f[0] != u'\x29c' || f[0] != u'\o{001234}'
68 || f[1] != u'\xbFFD' || f[1] != u'\o{137775}'
69 || f[2] != f[1])
70 __builtin_abort ();
71 if (g[0] != L'\u1234' || g[0] != L'\u{1234}'
72 || g[1] != L'\U0000BFFD' || g[1] != L'\u{00000bFfD}'
73 || g[2] != g[0]
74 || h[0] != L'\x1234' || h[0] != L'\x{001234}'
75 || h[1] != L'\xBFFD' || h[1] != L'\x{00bFfD}'
76 || h[2] != h[0]
77 || i[0] != L'\x29c' || i[0] != L'\o{001234}'
78 || i[1] != L'\xbFFD' || i[1] != L'\o{137775}'
79 || i[2] != i[1])
80 __builtin_abort ();
81 #ifdef __cplusplus
82 if (j[0] != '\u0034' || j[0] != '\u{034}'
83 || j[1] != '\U0000003D' || j[1] != '\u{000003d}')
84 __builtin_abort ();
85 #endif
86 if (k[0] != '\x034' || k[0] != '\x{0034}'
87 || k[1] != '\x3D' || k[1] != '\x{3d}'
88 || l[0] != '\x1c' || l[0] != '\o{0034}'
89 || l[1] != '\x07e' || l[1] != '\o{176}' || l[1] != '\176')
90 __builtin_abort ();
91 return 0;
92 }