From ed507b73ee264ad43c3017024472874406976c3f Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Sun, 14 Aug 2011 21:00:05 -0400 Subject: [PATCH] fix #3004 (false positive: (style) Struct 'Fred' hides typedef with same name) --- lib/tokenize.cpp | 2 +- test/testsimplifytokens.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 3ab5a4dd1..e9fa933ea 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -721,7 +721,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token duplicateTypedefError(*tokPtr, name, "Struct"); return true; } - else if (tok->next()->str() == ")") + else if (Token::Match(tok->next(), ")|*")) { return true; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 2e855bb48..3e322b922 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -267,6 +267,7 @@ private: TEST_CASE(simplifyTypedef99); // ticket #2999 TEST_CASE(simplifyTypedef100); // ticket #3000 TEST_CASE(simplifyTypedef101); // ticket #3003 (segmentation fault) + TEST_CASE(simplifyTypedef102); // ticket #3004 TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -5393,6 +5394,17 @@ private: ASSERT_EQUALS("[test.cpp:2]: (error) syntax error\n", errout.str()); } + void simplifyTypedef102() // ticket #3004 + { + const char code[] = "typedef struct { } Fred;\n" + "void foo()\n" + "{\n" + " Fred * Fred;\n" + "}\n"; + sizeof_(code); + ASSERT_EQUALS("", errout.str()); + } + void simplifyTypedefFunction1() { {