From d6e3b3d3f3dce841438845a0fd682713f6ce43e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 30 Jan 2014 17:31:06 +0100 Subject: [PATCH] ast: fixed syntax tree for 'a=(b)?1:0'. The parentheses should not be in the syntax tree --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index f8ecd2e3a..789f37214 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -377,7 +377,7 @@ static bool iscast(const Token *tok) for (const Token *tok2 = tok->next(); tok2; tok2 = tok2->next()) { if (!Token::Match(tok2, "%var%|*|&|::")) - return Token::Match(tok2, ") %any%") && (!tok2->next()->isOp() && !Token::Match(tok2->next(), "[[]);,]")); + return Token::Match(tok2, ") %any%") && (!tok2->next()->isOp() && !Token::Match(tok2->next(), "[[]);,?:]")); } return false; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 9a112e2bb..eaed38ccf 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -10152,6 +10152,7 @@ private: ASSERT_EQUALS("a1(2+=",testAst("a=(t*)1+2;")); ASSERT_EQUALS("a1(2+=",testAst("a=(t&)1+2;")); ASSERT_EQUALS("ab::r&c(=", testAst("a::b& r = (a::b&)c;")); // #5261 + ASSERT_EQUALS("ab1?0:=", testAst("a=(b)?1:0;")); // ({..}) ASSERT_EQUALS("a{+d+ bc+", testAst("a+({b+c;})+d"));