From 210b921062ac09ff52e2e9e7f09bee1cb3e5db0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 27 Mar 2018 13:44:28 +0200 Subject: [PATCH] Fixed #8462 (AST: no ast created for 'e = { std::move(address),httpPort, (httpsPort) };') --- lib/tokenlist.cpp | 6 ++++++ test/testtokenize.cpp | 1 + 2 files changed, 7 insertions(+) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 2eaf1e1b2..987131bdf 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -401,6 +401,12 @@ static bool iscast(const Token *tok) if (Token::Match(tok, "( (| typeof (") && Token::Match(tok->link(), ") %num%")) return true; + if (Token::Match(tok->link(), ") }|)|]")) + return false; + + if (Token::Match(tok->link(), ") %cop%") && !Token::Match(tok->link(), ") [&*+-~]")) + return false; + if (Token::Match(tok->previous(), "= ( %name% ) {") && tok->next()->varId() == 0) return true; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 1246d70a3..c08ae31ea 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8324,6 +8324,7 @@ private: ASSERT_EQUALS("s0[L.2[x={=", testAst("s = { [0].L[2] = x};")); ASSERT_EQUALS("ac.0={(=", testAst("a = (b){.c=0,};")); // <- useless comma ASSERT_EQUALS("xB[1y.z.1={(&=,{={=", testAst("x = { [B] = {1, .y = &(struct s) { .z=1 } } };")); + ASSERT_EQUALS("xab,c,{=", testAst("x={a,b,(c)};")); // struct initialization hang ASSERT_EQUALS("sbar.1{,{(={= fcmd( forfieldfield++;;(",