Debian Codegraph @

gcc/testsuite/g++.dg/cpp23/wchar-multi2.C

raw
1 // P2362R3 - Remove non-encodable wide character literals and multicharacter
2 // wide character literals.
3 // { dg-do compile }
4 // { dg-options "-fshort-wchar" }
5
6 char a = 'a';
7 int b = 'ab'; // { dg-warning "multi-character character constant" }
8 int c = '\u05D9'; // { dg-warning "multi-character character constant" }
9 #if __SIZEOF_INT__ > 2
10 int d = '\U0001F525'; // { dg-warning "multi-character character constant" "" { target int32 } }
11 #endif
12 int e = 'abcd'; // { dg-warning "multi-character character constant" }
13 wchar_t f = L'f';
14 wchar_t g = L'gh'; // { dg-error "multi-character literal cannot have an encoding prefix" "" { target c++23 } }
15 // { dg-warning "multi-character literal cannot have an encoding prefix" "" { target c++20_down } .-1 }
16 wchar_t h = L'ijkl'; // { dg-error "multi-character literal cannot have an encoding prefix" "" { target c++23 } }
17 // { dg-warning "multi-character literal cannot have an encoding prefix" "" { target c++20_down } .-1 }
18 wchar_t i = L'\U0001F525'; // { dg-error "character not encodable in a single code unit" "" { target { c++23 } } }
19 // { dg-warning "character not encodable in a single code unit" "" { target { c++20_down } } .-1 }
20 #ifdef __cpp_char8_t
21 typedef char8_t u8;
22 #else
23 typedef char u8;
24 #endif
25 #if __cpp_unicode_characters >= 201411
26 u8 j = u8'j';
27 u8 k = u8'kl'; // { dg-error "multi-character literal cannot have an encoding prefix" "" { target c++17 } }
28 u8 l = u8'\U0001F525'; // { dg-error "character not encodable in a single code unit" "" { target c++17 } }
29 #endif
30 #if __cpp_unicode_characters >= 200704
31 char16_t m = u'm';
32 char16_t n = u'no'; // { dg-error "multi-character literal cannot have an encoding prefix" "" { target c++11 } }
33 char16_t o = u'\u05D9';
34 char16_t p = u'\U0001F525'; // { dg-error "character not encodable in a single code unit" "" { target c++11 } }
35 char32_t q = U'm';
36 char32_t r = U'no'; // { dg-error "multi-character literal cannot have an encoding prefix" "" { target c++11 } }
37 char32_t s = U'\u05D9';
38 char32_t t = U'\U0001F525';
39 #endif
40 wchar_t u = L'\u0065\u0301'; // { dg-error "multi-character literal cannot have an encoding prefix" "" { target c++23 } }
41 // { dg-warning "multi-character literal cannot have an encoding prefix" "" { target c++20_down } .-1 }
42 wchar_t v = L'é'; // { dg-error "multi-character literal cannot have an encoding prefix" "" { target c++23 } }
43 // { dg-warning "multi-character literal cannot have an encoding prefix" "" { target c++20_down } .-1 }