@@ -4567,7 +4567,8 @@ auto Parser::parse_template_class_declaration(
45674567}
45684568
45694569auto Parser::parse_empty_or_attribute_declaration (
4570- DeclarationAST*& yyast, List<AttributeSpecifierAST*>* attributes) -> auto {
4570+ DeclarationAST*& yyast, List<AttributeSpecifierAST*>* attributes,
4571+ BindingContext ctx) -> auto {
45714572 LookaheadParser lookahead{this };
45724573
45734574 SourceLocation semicolonLoc;
@@ -4594,10 +4595,10 @@ auto Parser::parse_notypespec_function_definition(
45944595 DeclarationAST*& yyast, List<AttributeSpecifierAST*>* atributes,
45954596 const std::vector<TemplateDeclarationAST*>& templateDeclarations,
45964597 BindingContext ctx) -> bool {
4597- LookaheadParser lookahead{this };
4598-
45994598 if (!context_allows_function_definition (ctx)) return false ;
46004599
4600+ LookaheadParser lookahead{this };
4601+
46014602 DeclSpecs specs{this };
46024603 List<SpecifierAST*>* declSpecifierList = nullptr ;
46034604
@@ -4625,6 +4626,8 @@ auto Parser::parse_type_or_forward_declaration(
46254626 List<SpecifierAST*>* declSpecifierList, const DeclSpecs& specs,
46264627 const std::vector<TemplateDeclarationAST*>& templateDeclarations,
46274628 BindingContext ctx) -> bool {
4629+ if (ctx == BindingContext::kInitStatement ) return false ;
4630+
46284631 LookaheadParser lookahead{this };
46294632
46304633 List<AttributeSpecifierAST*>* trailingAttributes = nullptr ;
@@ -4738,7 +4741,7 @@ auto Parser::parse_simple_declaration(
47384741 if (parse_template_class_declaration (yyast, attributes, templateDeclarations,
47394742 ctx))
47404743 return true ;
4741- else if (parse_empty_or_attribute_declaration (yyast, attributes))
4744+ else if (parse_empty_or_attribute_declaration (yyast, attributes, ctx ))
47424745 return true ;
47434746 else if (parse_notypespec_function_definition (yyast, attributes,
47444747 templateDeclarations, ctx))
@@ -4864,7 +4867,8 @@ auto Parser::parse_simple_declaration(
48644867 auto declIt = &initDeclaratorList;
48654868
48664869 InitDeclaratorAST* initDeclarator = nullptr ;
4867- if (!parse_init_declarator (initDeclarator, declarator, decl)) return false ;
4870+ if (!parse_init_declarator (initDeclarator, declarator, decl, ctx))
4871+ return false ;
48684872
48694873 if (ctx == BindingContext::kTemplate ) {
48704874 auto declarator = initDeclarator->declarator ;
@@ -4879,7 +4883,7 @@ auto Parser::parse_simple_declaration(
48794883
48804884 while (match (TokenKind::T_COMMA, commaLoc)) {
48814885 InitDeclaratorAST* initDeclarator = nullptr ;
4882- if (!parse_init_declarator (initDeclarator, specs)) return false ;
4886+ if (!parse_init_declarator (initDeclarator, specs, ctx )) return false ;
48834887
48844888 *declIt = make_list_node (pool_, initDeclarator);
48854889 declIt = &(*declIt)->next ;
@@ -6742,17 +6746,18 @@ auto Parser::parse_placeholder_type_specifier(SpecifierAST*& yyast,
67426746}
67436747
67446748auto Parser::parse_init_declarator (InitDeclaratorAST*& yyast,
6745- const DeclSpecs& specs) -> bool {
6749+ const DeclSpecs& specs, BindingContext ctx)
6750+ -> bool {
67466751 DeclaratorAST* declarator = nullptr ;
67476752 Decl decl{specs};
67486753 if (!parse_declarator (declarator, decl)) return false ;
67496754
6750- return parse_init_declarator (yyast, declarator, decl);
6755+ return parse_init_declarator (yyast, declarator, decl, ctx );
67516756}
67526757
67536758auto Parser::parse_init_declarator (InitDeclaratorAST*& yyast,
6754- DeclaratorAST* declarator, Decl& decl)
6755- -> bool {
6759+ DeclaratorAST* declarator, Decl& decl,
6760+ BindingContext ctx) -> bool {
67566761 Symbol* declaredSynbol = nullptr ;
67576762 if (auto declId = decl.declaratorId ; declId) {
67586763 auto symbolType = GetDeclaratorType{this }(declarator, decl.specs .getType ());
0 commit comments