Skip to content

Commit 996d0c7

Browse files
committed
refactor: isolate condition to not forward declare specializations
1 parent 5614fe1 commit 996d0c7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ template<typename T> requires( std::is_void_v<T> )
2020
class t<T> {public: cpp2::i32 b {2};
2121
};
2222
template<typename T> extern cpp2::i32 v;// clang-format off
23-
template<> extern cpp2::i32 v<void>;// clang-format on
23+
// clang-format on
2424
auto main() -> int;
2525

2626

source/cppfront.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4885,12 +4885,19 @@ class cppfront
48854885

48864886
if (
48874887
printer.get_phase() == printer.phase0_type_decls
4888+
&& !n.is_namespace()
4889+
&& !n.is_type()
4890+
)
4891+
{
4892+
return;
4893+
}
4894+
4895+
// Do not forward declare specializations.
4896+
if (
4897+
n.is_specialization()
48884898
&& (
4889-
(
4890-
!n.is_namespace()
4891-
&& !n.is_type()
4892-
) ||
4893-
n.is_specialization()
4899+
(n.is_type() && printer.get_phase() == printer.phase0_type_decls)
4900+
|| (n.is_object() && printer.get_phase() == printer.phase1_type_defs_func_decls)
48944901
)
48954902
)
48964903
{

0 commit comments

Comments
 (0)