annotate clang/test/SemaTemplate/temp_arg_string_printing.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
236
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
1 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -ast-print %s | FileCheck %s
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
2
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
3 using size_t = __SIZE_TYPE__;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
4 static_assert(__has_builtin(__make_integer_seq));
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
5
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
6 template <class T, T... I> class idx_seq {};
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
7 template <size_t N> using make_idx_seq = __make_integer_seq<idx_seq, size_t, N>;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
8
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
9 template <class CharT, size_t N>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
10 struct Str {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
11 constexpr Str(CharT const (&s)[N]) : Str(s, make_idx_seq<N>()) {}
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
12 CharT value[N];
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
13
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
14 private:
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
15 template <size_t... I>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
16 constexpr Str(CharT const (&s)[N], idx_seq<size_t, I...>) : value{s[I]...} {}
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
17 };
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
18
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
19 template <Str> class ASCII {};
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
20
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
21 void not_string() {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
22 // CHECK{LITERAL}: ASCII<Str<int, 3>{{9, -1, 42}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
23 new ASCII<(int[]){9, -1, 42}>;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
24 // CHECK{LITERAL}: ASCII<Str<double, 3>{{3.140000e+00, 0.000000e+00, 4.200000e+01}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
25 new ASCII<(double[]){3.14, 0., 42.}>;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
26 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
27
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
28 void narrow() {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
29 // CHECK{LITERAL}: ASCII<Str<char, 1>{""}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
30 new ASCII<"">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
31 // CHECK{LITERAL}: ASCII<Str<char, 26>{"the quick brown fox jumps"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
32 new ASCII<"the quick brown fox jumps">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
33 // CHECK{LITERAL}: ASCII<Str<char, 29>{"OVER THE LAZY DOG 0123456789"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
34 new ASCII<"OVER THE LAZY DOG 0123456789">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
35 // CHECK{LITERAL}: ASCII<Str<char, 33>{"\\`~!@#$%^&*()_+-={}[]|\'\";:,.<>?/"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
36 new ASCII<R"(\`~!@#$%^&*()_+-={}[]|'";:,.<>?/)">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
37 // CHECK{LITERAL}: ASCII<Str<char, 8>{{101, 115, 99, 97, 112, 101, 0, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
38 new ASCII<"escape\0">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
39 // CHECK{LITERAL}: ASCII<Str<char, 9>{"escape\r\n"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
40 new ASCII<"escape\r\n">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
41 // CHECK{LITERAL}: ASCII<Str<char, 11>{"escape\\\t\f\v"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
42 new ASCII<"escape\\\t\f\v">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
43 // CHECK{LITERAL}: ASCII<Str<char, 10>{"escape\a\bc"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
44 new ASCII<"escape\a\b\c">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
45 // CHECK{LITERAL}: ASCII<Str<char, 5>{{110, 111, 116, 17, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
46 new ASCII<"not\x11">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
47 // CHECK{LITERAL}: ASCII<Str<char, 10>{{18, 20, 127, 16, 1, 32, 97, 98, 99, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
48 new ASCII<"\x12\x14\x7f\x10\x01 abc">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
49 // CHECK{LITERAL}: ASCII<Str<char, 11>{{18, 20, 127, 16, 1, 32, 97, 98, 99, 100, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
50 new ASCII<"\x12\x14\x7f\x10\x01 abcd">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
51 // CHECK{LITERAL}: ASCII<Str<char, 32>{"print more characters as string"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
52 new ASCII<"print more characters as string">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
53 // CHECK{LITERAL}: ASCII<Str<char, 44>{"print more characters as string, no uplimit"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
54 new ASCII<"print more characters as string, no uplimit">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
55 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
56
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
57 void wide() {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
58 // CHECK{LITERAL}: ASCII<Str<wchar_t, 1>{L""}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
59 new ASCII<L"">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
60 // CHECK{LITERAL}: ASCII<Str<wchar_t, 26>{L"the quick brown fox jumps"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
61 new ASCII<L"the quick brown fox jumps">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
62 // CHECK{LITERAL}: ASCII<Str<wchar_t, 29>{L"OVER THE LAZY DOG 0123456789"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
63 new ASCII<L"OVER THE LAZY DOG 0123456789">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
64 // CHECK{LITERAL}: ASCII<Str<wchar_t, 33>{L"\\`~!@#$%^&*()_+-={}[]|\'\";:,.<>?/"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
65 new ASCII<LR"(\`~!@#$%^&*()_+-={}[]|'";:,.<>?/)">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
66 // CHECK{LITERAL}: ASCII<Str<wchar_t, 8>{{101, 115, 99, 97, 112, 101, 0, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
67 new ASCII<L"escape\0">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
68 // CHECK{LITERAL}: ASCII<Str<wchar_t, 9>{L"escape\r\n"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
69 new ASCII<L"escape\r\n">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
70 // CHECK{LITERAL}: ASCII<Str<wchar_t, 11>{L"escape\\\t\f\v"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
71 new ASCII<L"escape\\\t\f\v">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
72 // CHECK{LITERAL}: ASCII<Str<wchar_t, 10>{L"escape\a\bc"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
73 new ASCII<L"escape\a\b\c">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
74 // CHECK{LITERAL}: ASCII<Str<wchar_t, 5>{{110, 111, 116, 17, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
75 new ASCII<L"not\x11">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
76 // CHECK{LITERAL}: ASCII<Str<wchar_t, 10>{{18, 20, 255, 22909, 136, 32, 97, 98, 99, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
77 new ASCII<L"\x12\x14\xff\x597d\x88 abc">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
78 // CHECK{LITERAL}: ASCII<Str<wchar_t, 11>{{18, 20, 255, 22909, 136, 32, 97, 98, 99, 100, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
79 new ASCII<L"\x12\x14\xff\x597d\x88 abcd">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
80 // CHECK{LITERAL}: ASCII<Str<wchar_t, 32>{L"print more characters as string"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
81 new ASCII<L"print more characters as string">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
82 // CHECK{LITERAL}: ASCII<Str<wchar_t, 44>{L"print more characters as string, no uplimit"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
83 new ASCII<L"print more characters as string, no uplimit">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
84 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
85
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
86 void utf8() {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
87 // CHECK{LITERAL}: ASCII<Str<char8_t, 1>{u8""}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
88 new ASCII<u8"">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
89 // CHECK{LITERAL}: ASCII<Str<char8_t, 33>{u8"\\`~!@#$%^&*()_+-={}[]|\'\";:,.<>?/"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
90 new ASCII<u8R"(\`~!@#$%^&*()_+-={}[]|'";:,.<>?/)">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
91 // CHECK{LITERAL}: ASCII<Str<char8_t, 8>{{101, 115, 99, 97, 112, 101, 0, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
92 new ASCII<u8"escape\0">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
93 // CHECK{LITERAL}: ASCII<Str<char8_t, 9>{u8"escape\r\n"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
94 new ASCII<u8"escape\r\n">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
95 // CHECK{LITERAL}: ASCII<Str<char8_t, 7>{{229, 165, 189, 239, 191, 189, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
96 new ASCII<u8"\u597d\ufffd">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
97 // CHECK{LITERAL}: ASCII<Str<char8_t, 44>{u8"print more characters as string, no uplimit"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
98 new ASCII<u8"print more characters as string, no uplimit">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
99 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
100
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
101 void utf16() {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
102 // CHECK{LITERAL}: ASCII<Str<char16_t, 1>{u""}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
103 new ASCII<u"">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
104 // CHECK{LITERAL}: ASCII<Str<char16_t, 33>{u"\\`~!@#$%^&*()_+-={}[]|\'\";:,.<>?/"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
105 new ASCII<uR"(\`~!@#$%^&*()_+-={}[]|'";:,.<>?/)">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
106 // CHECK{LITERAL}: ASCII<Str<char16_t, 8>{{101, 115, 99, 97, 112, 101, 0, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
107 new ASCII<u"escape\0">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
108 // CHECK{LITERAL}: ASCII<Str<char16_t, 9>{u"escape\r\n"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
109 new ASCII<u"escape\r\n">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
110 // CHECK{LITERAL}: ASCII<Str<char16_t, 3>{{22909, 65533, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
111 new ASCII<u"\u597d\ufffd">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
112 // CHECK{LITERAL}: ASCII<Str<char16_t, 44>{u"print more characters as string, no uplimit"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
113 new ASCII<u"print more characters as string, no uplimit">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
114 }
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
115
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
116 void utf32() {
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
117 // CHECK{LITERAL}: ASCII<Str<char32_t, 1>{U""}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
118 new ASCII<U"">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
119 // CHECK{LITERAL}: ASCII<Str<char32_t, 33>{U"\\`~!@#$%^&*()_+-={}[]|\'\";:,.<>?/"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
120 new ASCII<UR"(\`~!@#$%^&*()_+-={}[]|'";:,.<>?/)">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
121 // CHECK{LITERAL}: ASCII<Str<char32_t, 8>{{101, 115, 99, 97, 112, 101, 0, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
122 new ASCII<U"escape\0">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
123 // CHECK{LITERAL}: ASCII<Str<char32_t, 9>{U"escape\r\n"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
124 new ASCII<U"escape\r\n">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
125 // CHECK{LITERAL}: ASCII<Str<char32_t, 3>{{22909, 131358, 0}}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
126 new ASCII<U"\u597d\U0002011E">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
127 // CHECK{LITERAL}: ASCII<Str<char32_t, 44>{U"print more characters as string, no uplimit"}>
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
128 new ASCII<U"print more characters as string, no uplimit">;
c4bab56944e8 LLVM 16
kono
parents:
diff changeset
129 }