diff options
| author | Roberto Raggi <qtc-committer@nokia.com> | 2008-12-15 12:24:41 +0100 |
|---|---|---|
| committer | Roberto Raggi <qtc-committer@nokia.com> | 2008-12-15 12:25:32 +0100 |
| commit | da6eb8445650ee378a3c4bd1140b96629ec07065 (patch) | |
| tree | df215396abd9e99b42ffe321f9e27238b102f69b /shared/cplusplus | |
| parent | 78f1fca9aa55311a84b6a4cbd6507b70398fff39 (diff) | |
| download | qt-creator-da6eb8445650ee378a3c4bd1140b96629ec07065.tar.gz | |
Fixes: Parsing of simple id expressions (e.g. a;).
AutoTest: included
Diffstat (limited to 'shared/cplusplus')
| -rw-r--r-- | shared/cplusplus/Parser.cpp | 18 | ||||
| -rw-r--r-- | shared/cplusplus/Parser.h | 3 |
2 files changed, 18 insertions, 3 deletions
diff --git a/shared/cplusplus/Parser.cpp b/shared/cplusplus/Parser.cpp index 13fbaa0160..13ca6b2074 100644 --- a/shared/cplusplus/Parser.cpp +++ b/shared/cplusplus/Parser.cpp @@ -1760,7 +1760,7 @@ bool Parser::parseReturnStatement(StatementAST *&node) return false; } -bool Parser::maybeFunctionCall(SimpleDeclarationAST *simpleDecl) +bool Parser::maybeFunctionCall(SimpleDeclarationAST *simpleDecl) const { if (! simpleDecl) return false; @@ -1798,6 +1798,17 @@ bool Parser::maybeFunctionCall(SimpleDeclarationAST *simpleDecl) return true; } +bool Parser::maybeSimpleExpression(SimpleDeclarationAST *simpleDecl) const +{ + if (! simpleDecl->declarators) { + SpecifierAST *spec = simpleDecl->decl_specifier_seq; + if (spec && ! spec->next && spec->asNamedTypeSpecifier()) { + return true; + } + } + return false; +} + bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node) { if (LA() == T_SEMICOLON) @@ -1810,7 +1821,9 @@ bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node) SimpleDeclarationAST *simpleDecl = 0; if (stmt->declaration) simpleDecl = stmt->declaration->asSimpleDeclaration(); - if (simpleDecl && simpleDecl->decl_specifier_seq && ! maybeFunctionCall(simpleDecl)) { + + if (simpleDecl && simpleDecl->decl_specifier_seq && + ! maybeFunctionCall(simpleDecl) && ! maybeSimpleExpression(simpleDecl)) { unsigned end_of_declaration_statement = cursor(); rewind(start); StatementAST *expression = 0; @@ -1827,6 +1840,7 @@ bool Parser::parseExpressionOrDeclarationStatement(StatementAST *&node) return true; } } + blockErrors(blocked); rewind(start); return parseExpressionStatement(node); diff --git a/shared/cplusplus/Parser.h b/shared/cplusplus/Parser.h index f35b204166..fbaf423b6f 100644 --- a/shared/cplusplus/Parser.h +++ b/shared/cplusplus/Parser.h @@ -220,7 +220,8 @@ public: void match(int kind, unsigned *token); - bool maybeFunctionCall(SimpleDeclarationAST *simpleDecl); + bool maybeFunctionCall(SimpleDeclarationAST *simpleDecl) const; + bool maybeSimpleExpression(SimpleDeclarationAST *simpleDecl) const; private: bool switchTemplateArguments(bool templateArguments); |
