summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/AST.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-06-16 10:00:07 +0200
committerRoberto Raggi <roberto.raggi@nokia.com>2009-06-16 10:00:07 +0200
commit4164d31712ce330b506f3d1f8985e7d73d24afe4 (patch)
tree11bb12fba37d60c035420078fce808fe7a192a8e /src/shared/cplusplus/AST.cpp
parent1077631da9388c81d67580fe902b31b896e9ea85 (diff)
downloadqt-creator-4164d31712ce330b506f3d1f8985e7d73d24afe4.tar.gz
Fixed crash in SimpleDeclarationAST::lastToken()
Diffstat (limited to 'src/shared/cplusplus/AST.cpp')
-rw-r--r--src/shared/cplusplus/AST.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index 53098b4a5e..70d8b9223e 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -1170,15 +1170,23 @@ void DeclaratorListAST::accept0(ASTVisitor *visitor)
unsigned DeclaratorListAST::firstToken() const
{
+ if (comma_token)
+ return comma_token;
+
return declarator->firstToken();
}
unsigned DeclaratorListAST::lastToken() const
{
for (const DeclaratorListAST *it = this; it; it = it->next) {
- if (! it->next)
- return it->declarator->lastToken();
+ if (! it->next) {
+ if (it->declarator)
+ return it->declarator->lastToken();
+ else if (it->comma_token)
+ return it->comma_token + 1;
+ }
}
+
return 0;
}
@@ -2877,10 +2885,8 @@ unsigned SimpleDeclarationAST::lastToken() const
if (semicolon_token)
return semicolon_token + 1;
- for (DeclaratorListAST *it = declarators; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (declarators)
+ return declarators->lastToken();
for (SpecifierAST *it = decl_specifier_seq; it; it = it->next) {
if (! it->next)