diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e384f1fbb..4a638a5bd 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1876,7 +1876,7 @@ bool Tokenizer::tokenize(std::istream &code, for (const Token *tok = _tokens; tok; tok = tok->next()) { // skip executing scopes.. - if (Token::Match(tok, ") const| {")) + if (Token::Match(tok, ") const| {") || Token::simpleMatch(tok, ", {")) { while (tok->str() != "{") tok = tok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 40a276856..80057388b 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -49,6 +49,7 @@ private: TEST_CASE(tokenize9); TEST_CASE(tokenize10); TEST_CASE(tokenize11); + TEST_CASE(tokenize12); // don't freak out when the syntax is wrong TEST_CASE(wrong_syntax); @@ -436,6 +437,16 @@ private: ASSERT_EQUALS("X * sizeof ( Y ( ) ) ;", tokenizeAndStringify("X * sizeof(Y());", false)); } + // ticket #2118 - invalid syntax error + void tokenize12() + { + tokenizeAndStringify("Q_GLOBAL_STATIC_WITH_INITIALIZER(Qt4NodeStaticData, qt4NodeStaticData, {\n" + " for (unsigned i = 0 ; i < count; i++) {\n" + " }\n" + "});"); + ASSERT_EQUALS("", errout.str()); + } + void wrong_syntax() { {