From 724074f3a8a269a09c4e324a95b4875e38d12c06 Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Fri, 2 Jan 2009 17:54:01 +0100 Subject: [PATCH] Implemented EnumSpecifierAST::lastToken(). --- shared/cplusplus/AST.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/shared/cplusplus/AST.cpp b/shared/cplusplus/AST.cpp index b6d8f29d2c3..ffcc46a6810 100644 --- a/shared/cplusplus/AST.cpp +++ b/shared/cplusplus/AST.cpp @@ -1214,7 +1214,6 @@ unsigned ElaboratedTypeSpecifierAST::firstToken() const unsigned ElaboratedTypeSpecifierAST::lastToken() const { - assert(0 && "review me"); if (name) return name->lastToken(); return classkey_token + 1; @@ -1233,7 +1232,6 @@ unsigned EmptyDeclarationAST::firstToken() const unsigned EmptyDeclarationAST::lastToken() const { - assert(0 && "review me"); return semicolon_token + 1; } @@ -1254,8 +1252,20 @@ unsigned EnumSpecifierAST::firstToken() const unsigned EnumSpecifierAST::lastToken() const { - assert(0 && "review me"); - return rbrace_token + 1; + if (rbrace_token) + return rbrace_token + 1; + + for (EnumeratorAST *it = enumerators; it; it = it->next) { + if (! it->next) + return it->lastToken(); + } + + if (lbrace_token) + return lbrace_token + 1; + if (name) + return name->lastToken(); + + return enum_token + 1; } void EnumeratorAST::accept0(ASTVisitor *visitor)