@@ -3502,7 +3502,7 @@ bool Parser::parse_simple_declaration(DeclarationAST*& yyast,
35023502 const auto hasRequiresClause = parse_requires_clause (requiresClause);
35033503
35043504 if (acceptFunctionDefinition && functionDeclarator &&
3505- lookat_function_body ()) {
3505+ decl. type -> asFunctionType () && lookat_function_body ()) {
35063506 FunctionSymbol* functionSymbol = nullptr ;
35073507
35083508 if (decl.typeOrNamespaceSymbol ) {
@@ -6909,12 +6909,15 @@ bool Parser::parse_member_declaration_helper(DeclarationAST*& yyast) {
69096909
69106910 DeclaratorAST* declarator = nullptr ;
69116911
6912- if (parse_declarator (declarator) && getFunctionDeclarator (declarator)) {
6913- FunctionBodyAST* functionBody = nullptr ;
6912+ const auto hasDeclarator = parse_declarator (declarator);
69146913
6915- Semantics::DeclaratorSem decl{specs.specifiers };
6914+ Semantics::DeclaratorSem decl{specs.specifiers };
69166915
6917- sem->declarator (declarator, &decl);
6916+ if (hasDeclarator) sem->declarator (declarator, &decl);
6917+
6918+ if (hasDeclarator && decl.type ->asFunctionType () &&
6919+ getFunctionDeclarator (declarator)) {
6920+ FunctionBodyAST* functionBody = nullptr ;
69186921
69196922 RequiresClauseAST* requiresClause = nullptr ;
69206923
@@ -7003,7 +7006,7 @@ bool Parser::parse_member_declarator_list(List<InitDeclaratorAST*>*& yyast,
70037006
70047007 InitDeclaratorAST* initDeclarator = nullptr ;
70057008
7006- if (!parse_member_declarator (initDeclarator)) return false ;
7009+ if (!parse_member_declarator (initDeclarator, specs )) return false ;
70077010
70087011 Semantics::DeclaratorSem decl{specs.specifiers };
70097012
@@ -7017,7 +7020,7 @@ bool Parser::parse_member_declarator_list(List<InitDeclaratorAST*>*& yyast,
70177020 while (match (TokenKind::T_COMMA)) {
70187021 InitDeclaratorAST* initDeclarator = nullptr ;
70197022
7020- if (!parse_member_declarator (initDeclarator))
7023+ if (!parse_member_declarator (initDeclarator, specs ))
70217024 parse_error (" expected a declarator" );
70227025
70237026 if (initDeclarator) {
@@ -7035,7 +7038,8 @@ bool Parser::parse_member_declarator_list(List<InitDeclaratorAST*>*& yyast,
70357038 return true ;
70367039}
70377040
7038- bool Parser::parse_member_declarator (InitDeclaratorAST*& yyast) {
7041+ bool Parser::parse_member_declarator (InitDeclaratorAST*& yyast,
7042+ const DeclSpecs& specs) {
70397043 const auto start = currentLocation ();
70407044
70417045 SourceLocation identifierLoc;
@@ -7085,24 +7089,30 @@ bool Parser::parse_member_declarator(InitDeclaratorAST*& yyast) {
70857089
70867090 if (!parse_declarator (declarator)) return false ;
70877091
7092+ Semantics::DeclaratorSem decl{specs.specifiers };
7093+
7094+ sem->declarator (declarator, &decl);
7095+
70887096 auto ast = new (pool) InitDeclaratorAST ();
70897097 yyast = ast;
70907098
70917099 ast->declarator = declarator;
70927100
7093- RequiresClauseAST* requiresClause = nullptr ;
7101+ if (decl.type ->asFunctionType ()) {
7102+ RequiresClauseAST* requiresClause = nullptr ;
70947103
7095- if (parse_requires_clause (requiresClause)) {
7096- ast->requiresClause = requiresClause;
7097- } else {
7098- if (auto functionDeclarator = getFunctionDeclarator (declarator)) {
7104+ if (parse_requires_clause (requiresClause)) {
7105+ ast->requiresClause = requiresClause;
7106+ } else {
70997107 parse_virt_specifier_seq ();
71007108 parse_pure_specifier ();
7101- } else {
7102- parse_brace_or_equal_initializer (ast->initializer );
71037109 }
7110+
7111+ return true ;
71047112 }
71057113
7114+ parse_brace_or_equal_initializer (ast->initializer );
7115+
71067116 return true ;
71077117}
71087118
0 commit comments