diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 794b2d482..8448ff815 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1553,22 +1553,8 @@ static Token * createAstAtToken(Token *tok, bool cpp) typecount++; typetok = typetok->next(); } - if (Token::Match(typetok, "%var% =|[") && typetok->varId()) { - Token *tok2 = typetok->next(); - while (Token::simpleMatch(tok2, "[")) - tok2 = tok2->link()->next(); - if (Token::simpleMatch(tok2, "=")) { - AST_state state(cpp); - state.op.push(typetok); - Token * const start = tok2; - compileBinOp(tok2, state, compileAssignTernary); - if (tok2 == start || !tok2) - return start; - createAstAtTokenInner(start->next(), tok2, cpp); - return tok2; - } else if (Token::simpleMatch(tok2, ";")) - return tok; - } + if (Token::Match(typetok, "%var% =") && typetok->varId()) + tok = typetok; // Do not create AST for function declaration if (typetok && diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index a28d0a9b2..50632a02e 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7857,7 +7857,7 @@ private: void astvardecl() { // Variable declaration - ASSERT_EQUALS("var\"\"=", testAst("char var[1]=\"\";")); + ASSERT_EQUALS("a1[\"\"=", testAst("char a[1]=\"\";")); ASSERT_EQUALS("charp*(3[char5[3[new=", testAst("char (*p)[3] = new char[5][3];")); ASSERT_EQUALS("varp=", testAst("const int *var = p;"));