Skip to content

fix(cpp1): emit _template-head_ of variable template #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions regression-tests/pure2-bugfix-for-variable-template.cpp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
v0: <V: _> const int = 0;
main: () -> int = v0<0>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#define CPP2_USE_MODULES Yes

//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



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

#line 1 "pure2-bugfix-for-variable-template.cpp2"
template<auto V> extern int const v0;
[[nodiscard]] auto main() -> int;


//=== Cpp2 function definitions =================================================

#line 1 "pure2-bugfix-for-variable-template.cpp2"
template<auto V> int const v0 {0};
[[nodiscard]] auto main() -> int { return v0<0>; }

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pure2-bugfix-for-variable-template.cpp2... ok (all Cpp2, passes safety checks)

1 change: 1 addition & 0 deletions source/cppfront.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5066,6 +5066,7 @@ class cppfront
n.template_parameters
&& (
printer.get_phase() < printer.phase2_func_defs
|| n.is_object()
|| (
n.is_function()
&& n.has_name() // only if it is not unnambed function aka lambda
Expand Down