From dda5556ded2db86514969b1d4ba69a5f0f7caeb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 24 May 2017 20:24:56 +0200 Subject: [PATCH] Fixed #8034 (AST: better handling for c++ type initialization) --- 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 4ad9a9531..db82df873 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -386,7 +386,7 @@ static bool iscast(const Token *tok) // int(1), int*(2), .. static Token * findCppTypeInitPar(Token *tok) { - if (!tok || !Token::Match(tok->previous(), "[,(] %name%")) + if (!tok || !Token::Match(tok->previous(), "[,()] %name%")) return nullptr; while (Token::Match(tok, "%name%|::|<")) { if (tok->str() == "<") { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 332dbe5e5..9d4891dac 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7933,6 +7933,7 @@ private: // C++ : type() ASSERT_EQUALS("fint(0,(", testAst("f(int(),0);")); ASSERT_EQUALS("f(0,(", testAst("f(int *(),0);")); // typedef int* X; f(X(),0); + ASSERT_EQUALS("f((0,(", testAst("f((intp)int *(),0);")); // for ASSERT_EQUALS("for;;(", testAst("for(;;)"));