Skip to content

Commit ef5b963

Browse files
committed
fix(parse): permit unbraced function expression as template argument
1 parent 5aa17f8 commit ef5b963

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

source/parse.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ struct postfix_expression_node
721721
if (ops.empty()) {
722722
return false;
723723
} else {
724-
return (ops.front().op->type() == lexeme::Ampersand
724+
return (ops.front().op->type() == lexeme::Ampersand
725725
|| ops.front().op->type() == lexeme::Tilde);
726726
}
727727
}
@@ -3993,7 +3993,7 @@ class parser
39933993
// || curr().type() == lexeme::LeftBrace
39943994
)
39953995
{
3996-
bool inside_initializer = (
3996+
bool inside_initializer = (
39973997
peek(-1) && peek(-1)->type() == lexeme::Assignment
39983998
);
39993999
auto open_paren = &curr();
@@ -4015,12 +4015,12 @@ class parser
40154015
next();
40164016
if (
40174017
curr().type() != lexeme::Semicolon
4018-
&& curr().type() != lexeme::RightParen
4019-
&& curr().type() != lexeme::RightBracket
4018+
&& curr().type() != lexeme::RightParen
4019+
&& curr().type() != lexeme::RightBracket
40204020
&& curr().type() != lexeme::Comma
40214021
) {
40224022
expr_list->inside_initializer = false;
4023-
}
4023+
}
40244024
n->expr = std::move(expr_list);
40254025
return n;
40264026
}
@@ -4060,6 +4060,7 @@ class parser
40604060
&& curr().type() != lexeme::LeftParen // not imediatelly called
40614061
&& curr().type() != lexeme::RightParen // not as a last argument to function
40624062
&& curr().type() != lexeme::Comma // not as first or in-the-middle, function argument
4063+
&& curr().type() != lexeme::Greater // not as the last argument to template
40634064
&& curr().type() != lexeme::RightBracket // not as the last index argument
40644065
&& curr() != "is" // not as the argument to is
40654066
&& curr() != "as" // not as the argument to as
@@ -4382,7 +4383,7 @@ class parser
43824383
//G shift-expression '<<' additive-expression
43834384
//G shift-expression '>>' additive-expression
43844385
//G
4385-
auto shift_expression(bool allow_angle_operators = true)
4386+
auto shift_expression(bool allow_angle_operators = true)
43864387
-> auto
43874388
{
43884389
if (allow_angle_operators) {
@@ -4417,7 +4418,7 @@ class parser
44174418
//G shift-expression
44184419
//G compare-expression '<=>' shift-expression
44194420
//G
4420-
auto compare_expression(bool allow_angle_operators = true)
4421+
auto compare_expression(bool allow_angle_operators = true)
44214422
-> auto
44224423
{
44234424
return binary_expression<compare_expression_node> (
@@ -4433,7 +4434,7 @@ class parser
44334434
//G relational-expression '<=' compare-expression
44344435
//G relational-expression '>=' compare-expression
44354436
//G
4436-
auto relational_expression(bool allow_angle_operators = true)
4437+
auto relational_expression(bool allow_angle_operators = true)
44374438
-> auto
44384439
{
44394440
if (allow_angle_operators) {
@@ -4465,7 +4466,7 @@ class parser
44654466
//G equality-expression '==' relational-expression
44664467
//G equality-expression '!=' relational-expression
44674468
//G
4468-
auto equality_expression(bool allow_angle_operators = true)
4469+
auto equality_expression(bool allow_angle_operators = true)
44694470
-> auto
44704471
{
44714472
return binary_expression<equality_expression_node> (
@@ -4478,7 +4479,7 @@ class parser
44784479
//G equality-expression
44794480
//G bit-and-expression '&' equality-expression
44804481
//G
4481-
auto bit_and_expression(bool allow_angle_operators = true)
4482+
auto bit_and_expression(bool allow_angle_operators = true)
44824483
-> auto
44834484
{
44844485
return binary_expression<bit_and_expression_node> (
@@ -4491,7 +4492,7 @@ class parser
44914492
//G bit-and-expression
44924493
//G bit-xor-expression '^' bit-and-expression
44934494
//G
4494-
auto bit_xor_expression(bool allow_angle_operators = true)
4495+
auto bit_xor_expression(bool allow_angle_operators = true)
44954496
-> auto
44964497
{
44974498
return binary_expression<bit_xor_expression_node> (
@@ -4504,7 +4505,7 @@ class parser
45044505
//G bit-xor-expression
45054506
//G bit-or-expression '|' bit-xor-expression
45064507
//G
4507-
auto bit_or_expression(bool allow_angle_operators = true)
4508+
auto bit_or_expression(bool allow_angle_operators = true)
45084509
-> auto
45094510
{
45104511
return binary_expression<bit_or_expression_node> (
@@ -4517,7 +4518,7 @@ class parser
45174518
//G bit-or-expression
45184519
//G logical-and-expression '&&' bit-or-expression
45194520
//G
4520-
auto logical_and_expression(bool allow_angle_operators = true)
4521+
auto logical_and_expression(bool allow_angle_operators = true)
45214522
-> auto
45224523
{
45234524
return binary_expression<logical_and_expression_node> (
@@ -4532,7 +4533,7 @@ class parser
45324533
//G logical-and-expression
45334534
//G logical-or-expression '||' logical-and-expression
45344535
//G
4535-
auto logical_or_expression(bool allow_angle_operators = true)
4536+
auto logical_or_expression(bool allow_angle_operators = true)
45364537
-> auto
45374538
{
45384539
return binary_expression<logical_or_expression_node> (
@@ -4850,7 +4851,7 @@ class parser
48504851

48514852
n->open_angle = curr().position();
48524853
next();
4853-
4854+
48544855
auto term = unqualified_id_node::term{};
48554856

48564857
do {
@@ -6421,7 +6422,7 @@ class parser
64216422
}
64226423
assert (n->is_type());
64236424
}
6424-
6425+
64256426
// Or a function type, declaring a function - and tell the function whether it's in a user-defined type
64266427
else if (auto t = function_type(n.get(), named))
64276428
{
@@ -6569,11 +6570,11 @@ class parser
65696570
)
65706571
{
65716572
auto& type = std::get<declaration_node::an_object>(n->type);
6572-
// object initialized by the address of the curr() object
6573+
// object initialized by the address of the curr() object
65736574
if (peek(1)->type() == lexeme::Ampersand) {
65746575
type->address_of = &curr();
65756576
}
6576-
// object initialized by (potentially multiple) dereference of the curr() object
6577+
// object initialized by (potentially multiple) dereference of the curr() object
65776578
else if (peek(1)->type() == lexeme::Multiply) {
65786579
type->dereference_of = &curr();
65796580
for (int i = 1; peek(i)->type() == lexeme::Multiply; ++i)
@@ -6778,7 +6779,7 @@ class parser
67786779
return {};
67796780
}
67806781
if (
6781-
t->is_wildcard()
6782+
t->is_wildcard()
67826783
|| ( t->get_token() && t->get_token()->to_string(true) == "auto" )
67836784
) {
67846785
errors.emplace_back(

0 commit comments

Comments
 (0)