From 3c56ccc33feb993ee2f9fd2c172bdb00ea2e3dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 19 Apr 2020 17:00:08 +0200 Subject: [PATCH] Fixed #9531 (Syntax Error: AST broken, 'for' doesn't have two operands.) --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 81608d0f2..71af9366a 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -484,7 +484,7 @@ static Token * skipDecl(Token *tok) vartok = vartok->link(); else return tok; - } else if (Token::Match(vartok, "%name% [:=]")) { + } else if (Token::Match(vartok, "%var% [:=(]")) { return vartok; } vartok = vartok->next(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 4a6265489..ad508a98a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7484,10 +7484,11 @@ private: ASSERT_EQUALS("fora0=a8 c : d);")); - ASSERT_EQUALS("forde:(", testAst("for (a::b d : e);")); + ASSERT_EQUALS("forvarb:(", testAst("for (int *var : b);")); + ASSERT_EQUALS("forvard:(", testAst("for (a var : d);")); + ASSERT_EQUALS("forvare:(", testAst("for (a::b var : e);")); ASSERT_EQUALS("forx*0=yz;;(", testAst("for(*x=0;y;z)")); ASSERT_EQUALS("forx0=y(8