1 // RUN: %clang_cc1 -fchar8_t -std=c++17 -verify %s
2 // RUN: %clang_cc1 -std=c++2a -verify=expected %s
3 // RUN: %clang_cc1 -std=c++2a -verify=expected -fno-signed-char %s
9 char8_t d
[] = "foo"; // expected-error {{initializing 'char8_t' array with plain string literal}} expected-note {{add 'u8' prefix}}
15 unsigned char i
[] = u8
"foo";
16 unsigned char j
[] = { u8
"foo" };
18 char l
[] = { u8
"foo" };
19 signed char m
[] = u8
"foo"; // expected-error {{initialization of char array with UTF-8 string literal is not permitted}}
20 signed char n
[] = { u8
"foo" }; // expected-error {{cannot initialize an array element of type 'signed char' with an lvalue of type 'const char8_t[4]'}}
22 const unsigned char* uptr
= u8
"foo"; // expected-error {{cannot initialize}}
23 const signed char* sptr
= u8
"foo"; // expected-error {{cannot initialize}}
24 const char* ptr
= u8
"foo"; // expected-error {{cannot initialize}}
28 constexpr T c
[] = {0, static_cast<T
>(0xFF), 0x42};
29 constexpr T a
[] = u8
"\x00\xFF\x42";
31 static_assert(a
[0] == c
[0]);
32 static_assert(a
[1] == c
[1]);
33 static_assert(a
[2] == c
[2]);
36 void call_check_values() {
38 check_values
<unsigned char>();
45 void operator""_a(char);
46 void operator""_a(const char*, decltype(sizeof(0)));
49 int &x
= u8
'a'_a
; // expected-error {{no matching literal operator}}
50 float &y
= u8
"a"_a
; // expected-error {{no matching literal operator}}
53 int &operator""_a(char8_t
);
54 float &operator""_a(const char8_t
*, decltype(sizeof(0)));
61 template<typename E
, typename T
> void check(T
&&t
) {
65 void check_deduction() {
66 check
<char8_t
>(u8
'a');
67 check
<const char8_t(&)[5]>(u8
"a\u1000");
70 static_assert(sizeof(char8_t
) == 1);
71 static_assert(char8_t(-1) > 0);
72 static_assert(u8
"\u0080"[0] > 0);
83 void f(A
); // expected-note {{candidate}}
84 void f(B
); // expected-note {{candidate}}
87 f({u8
"foo"}); // expected-error {{call to 'f' is ambiguous}}