File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,15 @@ t: @struct <T: type> type = {
4
4
t: @struct <T: type> type < T> type requires std::is_void_v < T> = {
5
5
b: i32 = 2;
6
6
}
7
+ t: @struct type < i64> type = {
8
+ c: i32 = 3;
9
+ }
7
10
v: <T> i32 = 1; // clang-format off
8
11
v: <> type<void> i32 = 2; // clang-format on
9
12
main: () = {
10
13
[[assert Testing: t<i32>().a == 1]]
11
14
[[assert Testing: t<void>().b == 2]]
15
+ [[assert Testing: t<i64>().c == 3]]
12
16
[[assert Testing: (v<i32>) == 1]]
13
17
[[assert Testing: (v<void>) == 2]]
14
18
}
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ template<typename T> class t {
19
19
template <typename T> requires ( std::is_void_v<T> )
20
20
class t<T> {public: cpp2::i32 b {2 };
21
21
};
22
+ template <> class t <cpp2::i64 > {
23
+ public: cpp2::i32 c {3 };
24
+ };
22
25
template <typename T> extern cpp2::i32 v;// clang-format off
23
26
// clang-format on
24
27
auto main () -> int;
@@ -27,12 +30,13 @@ auto main() -> int;
27
30
// === Cpp2 function definitions =================================================
28
31
29
32
30
- #line 7 "pure2-template-specialization.cpp2"
33
+ #line 10 "pure2-template-specialization.cpp2"
31
34
template <typename T> cpp2::i32 v {1 };
32
35
template <> cpp2::i32 v<void > {2 };
33
36
auto main () -> int{
34
37
cpp2::Testing.expects (t<cpp2::i32 >().a ==1 , " " );
35
38
cpp2::Testing.expects (t<void >().b ==2 , " " );
39
+ cpp2::Testing.expects (t<cpp2::i64 >().c ==3 , " " );
36
40
cpp2::Testing.expects ((v<cpp2::i32 >)==1 , " " );
37
41
cpp2::Testing.expects ((v<void >)==2 , " " );
38
42
}
Original file line number Diff line number Diff line change @@ -5153,7 +5153,7 @@ class cppfront
5153
5153
5154
5154
// Now, emit our own template parameters
5155
5155
if (
5156
- n.template_parameters
5156
+ ( n.template_parameters || n. is_specialization ())
5157
5157
&& (
5158
5158
printer.get_phase () < printer.phase2_func_defs
5159
5159
|| n.is_object ()
@@ -5171,7 +5171,12 @@ class cppfront
5171
5171
)
5172
5172
{
5173
5173
printer.print_cpp2 (" template" , n.position ());
5174
- emit (*n.template_parameters , false , true );
5174
+ if (n.template_parameters ) {
5175
+ emit (*n.template_parameters , false , true );
5176
+ } else {
5177
+ assert (n.is_specialization ());
5178
+ printer.print_cpp2 (" <>" , n.position ());
5179
+ }
5175
5180
printer.print_cpp2 (" " , n.position ());
5176
5181
}
5177
5182
You can’t perform that action at this time.
0 commit comments