From f4ce5a37d7943327cdd35d10493dcab59ab35c7a Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 22 Apr 2010 20:08:29 +0200 Subject: [PATCH] Fixed #1615 (False positive - C-style pointer casting) --- lib/tokenize.cpp | 2 +- test/testsimplifytokens.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d4d3bd93e..dd76cd1d9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1030,7 +1030,7 @@ void Tokenizer::simplifyTypedef() { if (tok2->next()->str() == "(") tok2 = tok2->next()->link(); - else if (tok2->next()->str() != "[") + else if (!Token::Match(tok2->next(), "[|>")) { tok2 = tok2->next(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 9c7855651..5a2d51d2f 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -184,6 +184,7 @@ private: TEST_CASE(simplifyTypedef43); // ticket #1588 TEST_CASE(simplifyTypedef44); TEST_CASE(simplifyTypedef45); // ticket #1613 + TEST_CASE(simplifyTypedef46); // ticket #1615 TEST_CASE(reverseArraySyntax) TEST_CASE(simplify_numeric_condition) @@ -3893,6 +3894,21 @@ private: ASSERT_EQUALS("", errout.str()); } + void simplifyTypedef46() + { + // ticket # 1615 + const char code[] = "typedef void (*my_func)(arg_class*);\n" + "std::queue func_queue;"; + + // The expected result.. + const std::string expected("; " + "std :: queue < void ( * ) ( arg_class * ) > func_queue ;"); + ASSERT_EQUALS(expected, sizeof_(code)); + + checkSimplifyTypedef(code); + ASSERT_EQUALS("", errout.str()); + } + void reverseArraySyntax() { ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));