Skip to content

Commit 987768e

Browse files
committed
fix(cpp1): emit _template-head_ of variable template
1 parent 52a2798 commit 987768e

6 files changed

+28
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
v0: <V: _> const int = 0;
2+
main: () -> int = v0<0>;

regression-tests/test-results/gcc-13/pure2-bugfix-for-variable-template.cpp.execution

Whitespace-only changes.

regression-tests/test-results/gcc-13/pure2-bugfix-for-variable-template.cpp.output

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
#define CPP2_USE_MODULES Yes
3+
4+
//=== Cpp2 type declarations ====================================================
5+
6+
7+
#include "cpp2util.h"
8+
9+
10+
11+
//=== Cpp2 type definitions and function declarations ===========================
12+
13+
#line 1 "pure2-bugfix-for-variable-template.cpp2"
14+
template<auto V> extern int const v0;
15+
[[nodiscard]] auto main() -> int;
16+
17+
18+
//=== Cpp2 function definitions =================================================
19+
20+
#line 1 "pure2-bugfix-for-variable-template.cpp2"
21+
template<auto V> int const v0 {0};
22+
[[nodiscard]] auto main() -> int { return v0<0>; }
23+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pure2-bugfix-for-variable-template.cpp2... ok (all Cpp2, passes safety checks)
2+

source/cppfront.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5066,6 +5066,7 @@ class cppfront
50665066
n.template_parameters
50675067
&& (
50685068
printer.get_phase() < printer.phase2_func_defs
5069+
|| n.is_object()
50695070
|| (
50705071
n.is_function()
50715072
&& n.has_name() // only if it is not unnambed function aka lambda

0 commit comments

Comments
 (0)