diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2010-05-31 16:00:59 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2010-05-31 16:01:27 +0200 |
commit | 283019a44aee23d2c99c7012451d35ba56b46f28 (patch) | |
tree | 0b2c5e48e97e40833ff253f6a45f147da1b0ae02 /src/shared/cplusplus/Parser.cpp | |
parent | ecb951cab0e4628a04dfd084c610944948b4202e (diff) | |
download | qt-creator-283019a44aee23d2c99c7012451d35ba56b46f28.tar.gz |
Fixed possible crash when parsing template declarations at the end of a C++ file.
Diffstat (limited to 'src/shared/cplusplus/Parser.cpp')
-rw-r--r-- | src/shared/cplusplus/Parser.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 325135838e..6bde85f2e3 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -986,7 +986,7 @@ bool Parser::parseTemplateDeclaration(DeclarationAST *&node) match(T_GREATER, &ast->greater_token); } - do { + while (LA()) { unsigned start_declaration = cursor(); ast->declaration = 0; @@ -996,7 +996,7 @@ bool Parser::parseTemplateDeclaration(DeclarationAST *&node) _translationUnit->error(start_declaration, "expected a declaration"); rewind(start_declaration + 1); skipUntilDeclaration(); - } while (LA()); + } node = ast; return true; @@ -5825,3 +5825,11 @@ bool Parser::parseTrailingTypeSpecifierSeq(SpecifierListAST *&node) DEBUG_THIS_RULE(); return parseSimpleTypeSpecifier(node); } + +void Parser::rewind(unsigned cursor) +{ + if (cursor < _translationUnit->tokenCount()) + _tokenIndex = cursor; + else + _tokenIndex = _translationUnit->tokenCount() - 1; +} |