@@ -1362,50 +1362,27 @@ bool Parser::parseDeclarator(DeclaratorAST *&node)
13621362 return false ;
13631363 }
13641364
1365- std::size_t index = token_stream.cursor ();
1366- if (token_stream.lookAhead () == ' (' )
1365+ if (parseDeclaratorParametersAndSuffix (ast)) {
1366+
1367+ if (token_stream.lookAhead () == Token_identifier &&
1368+ token_stream.symbol (token_stream.cursor ())->as_string () == " override" )
13671369 {
13681370 nextToken ();
1369-
1370- ParameterDeclarationClauseAST *params = 0 ;
1371- if (!parseParameterDeclarationClause (params))
1372- {
1373- rewind (index);
1374- goto update_pos;
1375- }
1376-
1377- ast->parameter_declaration_clause = params;
1378-
1379- if (token_stream.lookAhead () != ' )' )
1380- {
1381- rewind (index);
1382- goto update_pos;
1383- }
1384-
1385- nextToken (); // skip ')'
1386-
1387- parseCvQualify (ast->fun_cv );
1388- parseExceptionSpecification (ast->exception_spec );
1389- if (token_stream.lookAhead () == Token_identifier) {
1390- const NameSymbol *name_symbol = token_stream.symbol (token_stream.cursor ());
1391- QString name = name_symbol->as_string ();
1392- if (name == " override" ) {
1393- nextToken ();
1394- ast->_override = true ;
1395- }
1396- }
1397- skipAttributes ();
1371+ ast->_override = true ;
13981372 }
1373+ skipAttributes ();
13991374
1400- if (skipParen)
1375+ if (skipParen)
14011376 {
14021377 if (token_stream.lookAhead () != ' )' )
1403- {
1404- reportError ((" ')' expected" ));
1405- }
1378+ {
1379+ reportError ((" ')' expected" ));
1380+ }
14061381 else
14071382 nextToken ();
14081383 }
1384+
1385+ }
14091386 }
14101387
14111388 update_pos:
@@ -1485,31 +1462,7 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
14851462 return false ;
14861463 }
14871464
1488- int index = (int ) token_stream.cursor ();
1489- if (token_stream.lookAhead () == ' (' )
1490- {
1491- nextToken ();
1492-
1493- ParameterDeclarationClauseAST *params = 0 ;
1494- if (!parseParameterDeclarationClause (params))
1495- {
1496- rewind (index);
1497- goto update_pos;
1498- }
1499-
1500- ast->parameter_declaration_clause = params;
1501-
1502- if (token_stream.lookAhead () != ' )' )
1503- {
1504- rewind (index);
1505- goto update_pos;
1506- }
1507-
1508- nextToken (); // skip ')'
1509-
1510- parseCvQualify (ast->fun_cv );
1511- parseExceptionSpecification (ast->exception_spec );
1512- }
1465+ parseDeclaratorParametersAndSuffix (ast);
15131466 }
15141467
15151468 update_pos:
@@ -1522,6 +1475,47 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
15221475 return true ;
15231476}
15241477
1478+ bool Parser::parseDeclaratorParametersAndSuffix (DeclaratorAST* ast)
1479+ {
1480+ std::size_t index = token_stream.cursor ();
1481+ if (token_stream.lookAhead () == ' (' )
1482+ {
1483+ nextToken ();
1484+
1485+ ParameterDeclarationClauseAST* params = 0 ;
1486+ if (!parseParameterDeclarationClause (params))
1487+ {
1488+ rewind (index);
1489+ return false ;
1490+ }
1491+
1492+ ast->parameter_declaration_clause = params;
1493+
1494+ if (token_stream.lookAhead () != ' )' )
1495+ {
1496+ rewind (index);
1497+ return false ;
1498+ }
1499+
1500+ nextToken (); // skip ')'
1501+
1502+ parseCvQualify (ast->fun_cv );
1503+ if (token_stream.lookAhead () == ' &' )
1504+ {
1505+ ast->valueRef = DeclaratorAST::Lvalue;
1506+ nextToken ();
1507+ }
1508+ else if (token_stream.lookAhead () == Token_and)
1509+ {
1510+ ast->valueRef = DeclaratorAST::Rvalue;
1511+ nextToken ();
1512+ }
1513+ parseExceptionSpecification (ast->exception_spec );
1514+ return true ;
1515+ }
1516+ return false ;
1517+ }
1518+
15251519bool Parser::parseEnumSpecifier (TypeSpecifierAST *&node)
15261520{
15271521 std::size_t start = token_stream.cursor ();
0 commit comments