Skip to content

Commit e63e15e

Browse files
committed
refactor: fix condition to not emit forward declaration of specialization
1 parent fe7ee05 commit e63e15e

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

regression-tests/test-results/pure2-template-specialization.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
#line 1 "pure2-template-specialization.cpp2"
1010
template <typename T> class t;
11-
template<typename T> requires( true )
12-
class t<T>;
11+
1312

1413
//=== Cpp2 type definitions and function declarations ===========================
1514

source/cppfront.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4885,9 +4885,13 @@ class cppfront
48854885

48864886
if (
48874887
printer.get_phase() == printer.phase0_type_decls
4888-
&& !n.is_namespace()
4889-
&& !n.is_type()
4890-
&& n.specialization_template_arguments == nullptr
4888+
&& (
4889+
(
4890+
!n.is_namespace()
4891+
&& !n.is_type()
4892+
) ||
4893+
n.is_specialization()
4894+
)
48914895
)
48924896
{
48934897
return;

source/parse.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,9 @@ struct declaration_node
25992599
auto is_alias() const -> bool
26002600
{ return type.index() == an_alias; }
26012601

2602+
auto is_specialization() const -> bool
2603+
{ return specialization_template_arguments != nullptr; }
2604+
26022605
auto is_polymorphic() const // has base types or virtual functions
26032606
-> bool
26042607
{

0 commit comments

Comments
 (0)