Debian Codegraph @

gcc/testsuite/g++.dg/ext/char8_t-char-literal-2.C

raw
1 // Test that UTF-8 character literals have type char8_t if -fchar8_t is enabled.
2 // { dg-do compile }
3 // { dg-options "-std=c++17 -fchar8_t" }
4
5 template<typename T1, typename T2>
6 struct is_same
7 { static const bool value = false; };
8 template<typename T>
9 struct is_same<T, T>
10 { static const bool value = true; };
11
12 static_assert(is_same<decltype(u8'x'), char8_t>::value, "Error");
13
14 #if u8'\0' - 1 < 0
15 #error "UTF-8 character literals not unsigned in preprocessor"
16 #endif