diff options
author | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-02-02 15:38:21 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@nokia.com> | 2010-02-02 15:39:42 +0100 |
commit | a3d0406d31bf7468cd1fe51683c73bd854e30a91 (patch) | |
tree | ea9c6186b6384d64d7384c4d0522880ee2fe5705 /src/shared/cplusplus/Parser.cpp | |
parent | fac977a5bde68b89ab29c964ea87a3007107ed09 (diff) | |
download | qt-creator-a3d0406d31bf7468cd1fe51683c73bd854e30a91.tar.gz |
Fixed throw expression parsing.
Diffstat (limited to 'src/shared/cplusplus/Parser.cpp')
-rw-r--r-- | src/shared/cplusplus/Parser.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 904f1a3189..61efa2baa8 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -182,7 +182,10 @@ inline bool isRightAssociative(int tokenKind) #endif #define PARSE_EXPRESSION_WITH_OPERATOR_PRECEDENCE(node, minPrecedence) { \ - if (!parseCastExpression(node)) \ + if (LA() == T_THROW) { \ + if (!parseThrowExpression(node)) \ + return false; \ + } else if (!parseCastExpression(node)) \ return false; \ \ parseExpressionWithOperatorPrecedence(node, minPrecedence); \ @@ -2322,14 +2325,27 @@ bool Parser::parseStringLiteral(ExpressionAST *&node) bool Parser::parseExpressionStatement(StatementAST *&node) { DEBUG_THIS_RULE(); - ExpressionAST *expression = 0; - if (LA() == T_SEMICOLON || parseExpression(expression)) { + if (LA() == T_SEMICOLON) { ExpressionStatementAST *ast = new (_pool) ExpressionStatementAST; - ast->expression = expression; match(T_SEMICOLON, &ast->semicolon_token); node = ast; return true; } + + ExpressionAST *expression = 0; + MemoryPool *oldPool = _pool; + MemoryPool tmp; + _pool = &tmp; + if (parseExpression(expression)) { + ExpressionStatementAST *ast = new (oldPool) ExpressionStatementAST; + ast->expression = expression->clone(oldPool); + match(T_SEMICOLON, &ast->semicolon_token); + node = ast; + _pool = oldPool; + return true; + } + _pool = oldPool; + return false; } |