@@ -7731,7 +7731,7 @@ class parser
77317731
77327732 // Now the main declaration
77337733 //
7734- if (!(n->declaration = declaration (false , true , is_template))) {
7734+ if (!(n->declaration = declaration (false , true , is_template, {}, false ))) {
77357735 pos = start_pos; // backtrack
77367736 return {};
77377737 }
@@ -8198,7 +8198,8 @@ class parser
81988198 std::unique_ptr<unqualified_id_node> id = {},
81998199 accessibility access = {},
82008200 bool is_variadic = false ,
8201- statement_node* my_stmt = {}
8201+ statement_node* my_stmt = {},
8202+ bool semicolon_allowed = true
82028203 )
82038204 -> std::unique_ptr<declaration_node>
82048205 {
@@ -8506,7 +8507,10 @@ class parser
85068507 // Then there may be a semicolon
85078508 // If there is a semicolon, eat it
85088509 if (!done () && curr ().type () == lexeme::Semicolon) {
8509- next ();
8510+ if (semicolon_allowed)
8511+ next ();
8512+ else
8513+ error (" unexpected semicolon after declaration" , {}, {}, {});
85108514 }
85118515 // But if there isn't one and it was required, diagnose an error
85128516 else if (semicolon_required) {
@@ -8932,7 +8936,8 @@ class parser
89328936 bool semicolon_required = true ,
89338937 bool is_parameter = false ,
89348938 bool is_template_parameter = false ,
8935- statement_node* my_stmt = {}
8939+ statement_node* my_stmt = {},
8940+ bool semicolon_allowed = true
89368941 )
89378942 -> std::unique_ptr<declaration_node>
89388943 {
@@ -9089,7 +9094,8 @@ class parser
90899094 std::move (id),
90909095 access,
90919096 is_variadic,
9092- my_stmt
9097+ my_stmt,
9098+ semicolon_allowed
90939099 );
90949100 if (!n) {
90959101 pos = start_pos; // backtrack
0 commit comments