[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdevelop] languages/cpp/parser: fix parsing of initializer lists with trailing comma
From: Milian Wolff <mail () milianw ! de>
Date: 2012-03-01 1:08:25
Message-ID: 20120301010825.1D838A60A9 () git ! kde ! org
[Download RAW message or body]
Git commit f4451a448bac4f7ca3f5ec999af346aaf5f51b6f by Milian Wolff.
Committed on 01/03/2012 at 02:07.
Pushed by mwolff into branch 'master'.
fix parsing of initializer lists with trailing comma
those are valid and we do want to have a proper list
with associated elements in such cases
before we said it was valid yet didn't get a filled
list back...
M +11 -8 languages/cpp/parser/parser.cpp
http://commits.kde.org/kdevelop/f4451a448bac4f7ca3f5ec999af346aaf5f51b6f
diff --git a/languages/cpp/parser/parser.cpp b/languages/cpp/parser/parser.cpp
index 4435cb3..50c09a8 100644
--- a/languages/cpp/parser/parser.cpp
+++ b/languages/cpp/parser/parser.cpp
@@ -2746,13 +2746,6 @@ bool Parser::parseBracedInitList(ExpressionAST*& node)
InitializerListAST *list = 0;
parseInitializerList(list);
- if (list && session->token_stream->lookAhead() == ',') {
- // see https://bugs.kde.org/show_bug.cgi?id=233328
- // and grammar spec on braced-init-list
- // init lists may have a trailing comma
- advance();
- }
-
CHECK('}');
BracedInitListAST *ast = CreateNode<BracedInitListAST>(session->mempool);
@@ -2772,7 +2765,17 @@ bool Parser::parseInitializerList(InitializerListAST *&node)
do
{
if (clauses)
- advance(); // skip ',' separator between clauses
+ {
+ advance(); // skip ',' separator between clauses
+
+ if (session->token_stream->lookAhead() == '}')
+ {
+ // see https://bugs.kde.org/show_bug.cgi?id=233328
+ // and grammar spec on braced-init-list
+ // init lists may have a trailing comma
+ break;
+ }
+ }
InitializerClauseAST *init_clause = 0;
if (!parseInitializerClause(init_clause))
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic