Skip to content

Commit 6e88091

Browse files
committed
fix: apply rebase correctly
1 parent b0f7565 commit 6e88091

File tree

4 files changed

+43
-39
lines changed

4 files changed

+43
-39
lines changed

regression-tests/test-results/pure2-bugfix-for-multi-token-type-prvalue.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
//=== Cpp2 type definitions and function declarations ===========================
1212

1313
#line 1 "pure2-bugfix-for-multi-token-type-prvalue.cpp2"
14-
auto main(int const argc_, char const* const* const argv_) -> int;
14+
auto main(int const argc_, char** argv_) -> int;
1515

1616

1717
//=== Cpp2 function definitions =================================================
1818

1919
#line 1 "pure2-bugfix-for-multi-token-type-prvalue.cpp2"
20-
auto main(int const argc_, char const* const* const argv_) -> int{
20+
auto main(int const argc_, char** argv_) -> int{
2121
auto args = cpp2::make_args(argc_, argv_);
2222
#line 1 "pure2-bugfix-for-multi-token-type-prvalue.cpp2"
23-
(void) std::type_identity_t<int*>{&args.argc}; }
23+
static_cast<void>(std::type_identity_t<int*>{&args.argc}); }
2424

regression-tests/test-results/pure2-function-type-id.cpp

+21-18
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ template<cpp2::fn_t<cpp2::fn_t<void()>*()>* V> auto g() -> void;
2525

2626
// In non-local function return type.
2727
[[nodiscard]] auto g1() -> cpp2::fn_t<void()>*;
28-
template<bool V> [[nodiscard]] auto g1() -> cpp2::fn_t<void()>*;
28+
template<bool V> [[nodiscard]] auto g1() -> cpp2::fn_t<void()>*
29+
CPP2_REQUIRES (V)
30+
#line 90 "pure2-function-type-id.cpp2"
31+
;
2932
[[nodiscard]] auto g2() -> cpp2::fn_t<cpp2::fn_t<void()>*()>*;
3033

3134
// clang-format off
@@ -71,14 +74,14 @@ auto main() -> int{
7174
static_assert((std::is_const_v<decltype(f11)>)==std::is_const_v<decltype(i1)>);
7275
static_assert((std::is_const_v<decltype(f12)>)==std::is_const_v<decltype(i2)>);
7376
static_assert((std::is_const_v<decltype(f13)>)==std::is_const_v<decltype(i3)>);
74-
(void) std::move(f10);
75-
(void) std::move(f11);
76-
(void) std::move(f12);
77-
(void) std::move(f13);
78-
(void) std::move(i0);
79-
(void) std::move(i1);
80-
(void) std::move(i2);
81-
(void) std::move(i3);
77+
static_cast<void>(std::move(f10));
78+
static_cast<void>(std::move(f11));
79+
static_cast<void>(std::move(f12));
80+
static_cast<void>(std::move(f13));
81+
static_cast<void>(std::move(i0));
82+
static_cast<void>(std::move(i1));
83+
static_cast<void>(std::move(i2));
84+
static_cast<void>(std::move(i3));
8285

8386
// Variables with various kinds of parameter.
8487
cpp2::fn_t<void(cpp2::in<cpp2::i32>)>* f5 {[](cpp2::in<cpp2::i32> x) -> void{}};
@@ -112,21 +115,21 @@ cpp2::in<cpp2::fn_t<void()>> f = *cpp2::assert_not_null(f0);
112115

113116
// As local function parameter.
114117
#line 62 "pure2-function-type-id.cpp2"
115-
(void) [](cpp2::in<cpp2::fn_t<void()>> f) -> void{};
116-
(void) [](cpp2::fn_t<void()>* f) -> void{};
117-
(void) [](cpp2::fn_t<cpp2::fn_t<void()>*()>* f) -> void{};
118-
(void) [](cpp2::fn_t<cpp2::fn_t<cpp2::fn_t<void()>*()>*()>* f) -> void{};
118+
static_cast<void>([](cpp2::in<cpp2::fn_t<void()>> f) -> void{});
119+
static_cast<void>([](cpp2::fn_t<void()>* f) -> void{});
120+
static_cast<void>([](cpp2::fn_t<cpp2::fn_t<void()>*()>* f) -> void{});
121+
static_cast<void>([](cpp2::fn_t<cpp2::fn_t<cpp2::fn_t<void()>*()>*()>* f) -> void{});
119122

120123
// In local function return type.
121-
(void) [_0 = f0]() -> cpp2::fn_t<void()>& { return *cpp2::assert_not_null(_0); };
122-
(void) []() -> cpp2::fn_t<void()>* { return nullptr; };
123-
(void) []() -> cpp2::fn_t<cpp2::fn_t<void()>*()>* { return nullptr; };
124+
static_cast<void>([_0 = f0]() -> cpp2::fn_t<void()>& { return *cpp2::assert_not_null(_0); });
125+
static_cast<void>([]() -> cpp2::fn_t<void()>* { return nullptr; });
126+
static_cast<void>([]() -> cpp2::fn_t<cpp2::fn_t<void()>*()>* { return nullptr; });
124127

125128
// With `!throws`.
126-
(void) std::type_identity_t<cpp2::fn_t<void(std::string_view, CPP2_MESSAGE_PARAM) noexcept>*>{cpp2::report_and_terminate};
129+
static_cast<void>(std::type_identity_t<cpp2::fn_t<void(std::string_view, CPP2_MESSAGE_PARAM) noexcept>*>{cpp2::report_and_terminate});
127130

128131
// As template argument.
129-
(void) std::type_identity_t<cpp2::fn_t<void()>*>{std::move(f0)};
132+
static_cast<void>(std::type_identity_t<cpp2::fn_t<void()>*>{std::move(f0)});
130133
static_assert(std::is_function_v<cpp2::fn_t<void()>>);
131134
}
132135

source/cppfront.cpp

+7-13
Original file line numberDiff line numberDiff line change
@@ -975,15 +975,6 @@ class positional_printer
975975
};
976976

977977

978-
template <typename T>
979-
auto stack_value(T& var, std::type_identity_t<T> const& value)
980-
-> auto
981-
{
982-
return finally([&var, old = std::exchange(var, value)]() {
983-
var = old;
984-
});
985-
};
986-
987978
//-----------------------------------------------------------------------
988979
//
989980
// cppfront: a compiler instance
@@ -3762,7 +3753,7 @@ class cppfront
37623753
printer.print_extra( "{");
37633754
for (auto& param : n.parameters->parameters) {
37643755
printer.print_extra( "\n");
3765-
printer.print_extra( print_to_string(*param, false, false, true) );
3756+
printer.print_extra( print_to_string(*param, false, false, false) );
37663757
}
37673758
}
37683759

@@ -3849,7 +3840,6 @@ class cppfront
38493840
parameter_declaration_node const& n,
38503841
bool is_returns = false,
38513842
bool is_template_parameter = false,
3852-
bool is_statement_parameter = false,
38533843
bool in_function_type_id = false
38543844
)
38553845
-> void
@@ -4017,7 +4007,11 @@ class cppfront
40174007

40184008
// First any prefix
40194009

4020-
if (identifier == "_") {
4010+
if (
4011+
identifier == "_"
4012+
&& !in_function_type_id
4013+
)
4014+
{
40214015
printer.print_cpp2( "[[maybe_unused]] ", n.position() );
40224016
identifier = "param" + std::to_string(n.ordinal);
40234017
}
@@ -4170,7 +4164,7 @@ class cppfront
41704164
}
41714165
prev_pos = x->position();
41724166
assert(x);
4173-
emit(*x, is_returns, is_template_parameter, false, in_function_type_id);
4167+
emit(*x, is_returns, is_template_parameter, in_function_type_id);
41744168
if (!x->declaration->has_name("this")) {
41754169
first = false;
41764170
}

source/parse.h

+12-5
Original file line numberDiff line numberDiff line change
@@ -3766,6 +3766,15 @@ struct translation_unit_node
37663766
};
37673767

37683768

3769+
template <typename T>
3770+
auto stack_value(T& var, std::type_identity_t<T> const& value)
3771+
-> auto
3772+
{
3773+
return finally([&var, old = std::exchange(var, value)]() {
3774+
var = old;
3775+
});
3776+
};
3777+
37693778
//-----------------------------------------------------------------------
37703779
//
37713780
// parser: parses a section of Cpp2 code
@@ -5096,6 +5105,7 @@ class parser
50965105
auto term = unqualified_id_node::term{};
50975106

50985107
do {
5108+
auto stack = stack_value(start_pos, pos);
50995109
// If it doesn't start with * or const (which can only be a type id),
51005110
// try parsing it as an expression
51015111
if (auto e = [&]{
@@ -5121,14 +5131,11 @@ class parser
51215131
term.arg = std::move(e);
51225132
}
51235133

5124-
// Else try parsing it as a type id
5125-
else if (auto i = type_id()) {
5126-
term.arg = std::move(i);
5127-
}
5128-
51295134
else {
51305135
errors.clear();
51315136
pos = start_pos;
5137+
5138+
// Else try parsing it as a type id
51325139
if (auto i = type_id()) {
51335140
term.arg = std::move(i);
51345141
}

0 commit comments

Comments
 (0)