From ed12b4dc44b9c2aceede797f07a3ce21cf37e182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 3 Jan 2016 09:37:38 +0100 Subject: [PATCH] Fixed #7253 (AST wrong on nested reinterpret_cast) --- lib/tokenlist.cpp | 3 +++ test/testtokenize.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 025199a32..971e00f43 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -446,6 +446,9 @@ static bool iscast(const Token *tok) if (tok->previous() && tok->previous()->isName() && tok->previous()->str() != "return") return false; + if (Token::simpleMatch(tok->previous(), ">") && tok->previous()->link()) + return false; + if (Token::Match(tok, "( (| typeof (") && Token::Match(tok->link(), ") %num%")) return true; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 884c444f6..259faff6e 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8242,6 +8242,8 @@ private: ASSERT_EQUALS("a(3==", testAst("a()==3")); ASSERT_EQUALS("ab(== f(", testAst("a == b(); f();")); ASSERT_EQUALS("static_casta(i[", testAst("; static_cast(a)[i];")); // #6203 + ASSERT_EQUALS("reinterpret_castreinterpret_castptr(123&(", + testAst(";reinterpret_cast(reinterpret_cast(ptr) & 123);")); // #7253 // This two unit tests were added to avoid a crash. The actual correct AST result for non-executable code has not been determined so far. ASSERT_EQUALS("Cpublica::b:::", testAst("class C : public ::a::b { };"));