@@ -7731,7 +7731,7 @@ class parser
7731
7731
7732
7732
// Now the main declaration
7733
7733
//
7734
- if (!(n->declaration = declaration (false , true , is_template))) {
7734
+ if (!(n->declaration = declaration (false , true , is_template, {}, false ))) {
7735
7735
pos = start_pos; // backtrack
7736
7736
return {};
7737
7737
}
@@ -8198,7 +8198,8 @@ class parser
8198
8198
std::unique_ptr<unqualified_id_node> id = {},
8199
8199
accessibility access = {},
8200
8200
bool is_variadic = false ,
8201
- statement_node* my_stmt = {}
8201
+ statement_node* my_stmt = {},
8202
+ bool semicolon_allowed = true
8202
8203
)
8203
8204
-> std::unique_ptr<declaration_node>
8204
8205
{
@@ -8506,7 +8507,10 @@ class parser
8506
8507
// Then there may be a semicolon
8507
8508
// If there is a semicolon, eat it
8508
8509
if (!done () && curr ().type () == lexeme::Semicolon) {
8509
- next ();
8510
+ if (semicolon_allowed)
8511
+ next ();
8512
+ else
8513
+ error (" unexpected semicolon after declaration" , {}, {}, {});
8510
8514
}
8511
8515
// But if there isn't one and it was required, diagnose an error
8512
8516
else if (semicolon_required) {
@@ -8932,7 +8936,8 @@ class parser
8932
8936
bool semicolon_required = true ,
8933
8937
bool is_parameter = false ,
8934
8938
bool is_template_parameter = false ,
8935
- statement_node* my_stmt = {}
8939
+ statement_node* my_stmt = {},
8940
+ bool semicolon_allowed = true
8936
8941
)
8937
8942
-> std::unique_ptr<declaration_node>
8938
8943
{
@@ -9089,7 +9094,8 @@ class parser
9089
9094
std::move (id),
9090
9095
access ,
9091
9096
is_variadic,
9092
- my_stmt
9097
+ my_stmt,
9098
+ semicolon_allowed
9093
9099
);
9094
9100
if (!n) {
9095
9101
pos = start_pos; // backtrack
0 commit comments