blob: 5eb3d7062d2c2cc9f26728b91a6a4217357e0f13 [file] [log] [blame]
Richard Smith3a8244d2018-05-01 05:02:45 +00001// RUN: %clang_cc1 -fchar8_t -std=c++2a -verify %s
2
3char8_t a = u8'a';
4char8_t b[] = u8"foo";
5char8_t c = 'a';
6char8_t d[] = "foo"; // expected-error {{initializing 'char8_t' array with plain string literal}} expected-note {{add 'u8' prefix}}
7
8char e = u8'a';
9char f[] = u8"foo"; // expected-error {{initialization of char array with UTF-8 string literal is not permitted by '-fchar8_t'}}
10char g = 'a';
11char h[] = "foo";
12
13void disambig() {
14 char8_t (a) = u8'x';
15}
16
17void operator""_a(char);
18void operator""_a(const char*, decltype(sizeof(0)));
19
20void test_udl1() {
21 int &x = u8'a'_a; // expected-error {{no matching literal operator}}
22 float &y = u8"a"_a; // expected-error {{no matching literal operator}}
23}
24
25int &operator""_a(char8_t);
26float &operator""_a(const char8_t*, decltype(sizeof(0)));
27
28void test_udl2() {
29 int &x = u8'a'_a;
30 float &y = u8"a"_a;
31}
32
33template<typename E, typename T> void check(T &&t) {
34 using Check = E;
35 using Check = T;
36}
37void check_deduction() {
38 check<char8_t>(u8'a');
39 check<const char8_t(&)[5]>(u8"a\u1000");
40}
41
42static_assert(sizeof(char8_t) == 1);
43static_assert(char8_t(-1) > 0);
44static_assert(u8"\u0080"[0] > 0);