Skip to content

Commit c388eff

Browse files
committed
Start to do a javascript metafunction, and fix pointer parameter passing lowering
1 parent a7db592 commit c388eff

File tree

11 files changed

+1157
-1072
lines changed

11 files changed

+1157
-1072
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pure2-default-arguments.cpp2:6:61: error: no member named 'source_location' in namespace 'std'
2-
char const* fn = CPP2_UFCS_NONLOCAL(function_name)(std::source_location::current())
3-
~~~~~^
1+
pure2-default-arguments.cpp2:6:77: error: no member named 'source_location' in namespace 'std'
2+
cpp2::impl::in<char const*> fn = CPP2_UFCS_NONLOCAL(function_name)(std::source_location::current())
3+
~~~~~^
44
1 error generated.

regression-tests/test-results/gcc-10-c++20/pure2-default-arguments.cpp.output

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ In file included from pure2-default-arguments.cpp:7:
44
../../../include/cpp2util.h:10047:15: note: in expansion of macro ‘CPP2_FORWARD’
55
../../../include/cpp2util.h:10066:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’
66
../../../include/cpp2util.h:10096:59: note: in expansion of macro ‘CPP2_UFCS_’
7-
pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
7+
pure2-default-arguments.cpp2:6:38: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
88
../../../include/cpp2util.h:10047:92: error: local variable ‘params’ may not appear in this context
99
../../../include/cpp2util.h:10008:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’
1010
../../../include/cpp2util.h:10047:79: note: in expansion of macro ‘CPP2_FORWARD’
1111
../../../include/cpp2util.h:10066:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’
1212
../../../include/cpp2util.h:10096:59: note: in expansion of macro ‘CPP2_UFCS_’
13-
pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
13+
pure2-default-arguments.cpp2:6:38: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
1414
../../../include/cpp2util.h:10048:74: error: local variable ‘obj’ may not appear in this context
1515
../../../include/cpp2util.h:10008:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’
1616
../../../include/cpp2util.h:10048:61: note: in expansion of macro ‘CPP2_FORWARD’
1717
../../../include/cpp2util.h:10066:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’
1818
../../../include/cpp2util.h:10096:59: note: in expansion of macro ‘CPP2_UFCS_’
19-
pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
19+
pure2-default-arguments.cpp2:6:38: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
2020
../../../include/cpp2util.h:10048:93: error: local variable ‘params’ may not appear in this context
2121
../../../include/cpp2util.h:10008:34: note: in definition of macro ‘CPP2_UFCS_IDENTITY’
2222
../../../include/cpp2util.h:10048:80: note: in expansion of macro ‘CPP2_FORWARD’
2323
../../../include/cpp2util.h:10066:22: note: in expansion of macro ‘CPP2_UFCS_CONSTRAINT_ARG’
2424
../../../include/cpp2util.h:10096:59: note: in expansion of macro ‘CPP2_UFCS_’
25-
pure2-default-arguments.cpp2:6:22: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
26-
pure2-default-arguments.cpp2:6:61: error: ‘std::source_location’ has not been declared
25+
pure2-default-arguments.cpp2:6:38: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’
26+
pure2-default-arguments.cpp2:6:77: error: ‘std::source_location’ has not been declared
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pure2-default-arguments.cpp
2+
pure2-default-arguments.cpp2(6): error C7595: 'std::source_location::current': call to immediate function is not a constant expression

regression-tests/test-results/pure2-default-arguments.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ template<typename T = int, int N = 42> class myclass;
2121
// Older compilers will emit failures for this test case.
2222
#line 5 "pure2-default-arguments.cpp2"
2323
auto my_function_name(
24-
char const* fn = CPP2_UFCS_NONLOCAL(function_name)(std::source_location::current())
24+
cpp2::impl::in<char const*> fn = CPP2_UFCS_NONLOCAL(function_name)(std::source_location::current())
2525
) -> void;
2626

2727
#line 12 "pure2-default-arguments.cpp2"
@@ -58,7 +58,7 @@ auto main(int const argc_, char** argv_) -> int;
5858

5959
#line 5 "pure2-default-arguments.cpp2"
6060
auto my_function_name(
61-
char const* fn
61+
cpp2::impl::in<char const*> fn
6262
) -> void
6363
{
6464
std::cout << "calling: " + cpp2::to_string(fn) + "\n";

regression-tests/test-results/pure2-types-order-independence-and-nesting.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class X {
6464
class Y {
6565
private: X* px;
6666

67-
public: Y(X* x);
67+
public: Y(cpp2::impl::in<X*> x);
6868
#line 49 "pure2-types-order-independence-and-nesting.cpp2"
69-
public: auto operator=(X* x) -> Y& ;
69+
public: auto operator=(cpp2::impl::in<X*> x) -> Y& ;
7070

7171
public: auto why(cpp2::impl::in<int> count) const& -> void;
7272
public: Y(Y const&) = delete; /* No 'that' constructor, suppress copy */
@@ -157,10 +157,10 @@ namespace N {
157157
}
158158

159159
#line 49 "pure2-types-order-independence-and-nesting.cpp2"
160-
Y::Y(X* x)
160+
Y::Y(cpp2::impl::in<X*> x)
161161
: px{ x }{}
162162
#line 49 "pure2-types-order-independence-and-nesting.cpp2"
163-
auto Y::operator=(X* x) -> Y& {
163+
auto Y::operator=(cpp2::impl::in<X*> x) -> Y& {
164164
px = x;
165165
return *this; }
166166

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
cppfront compiler v0.8.2 Build A826:0706
2+
cppfront compiler v0.8.2 Build A827:1455
33
SPDX-License-Identifier Apache-2.0 WITH LLVM-exception
44
Copyright (c) 2022-2025 Herb Sutter

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"A826:0706"
1+
"A827:1455"

source/parse.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,6 +3542,7 @@ struct declaration_node
35423542
// Attributes currently configurable only via metafunction API,
35433543
// not directly in the base language grammar
35443544
bool member_function_generation = true;
3545+
bool ref_qualifier_generation = true;
35453546

35463547
// Cache some context
35473548
bool is_a_template_parameter = false;
@@ -3637,6 +3638,12 @@ struct declaration_node
36373638
member_function_generation = false;
36383639
}
36393640

3641+
auto type_disable_ref_qualifier_generation()
3642+
-> void
3643+
{
3644+
ref_qualifier_generation = false;
3645+
}
3646+
36403647
auto object_type() const
36413648
-> std::string
36423649
{

0 commit comments

Comments
 (0)