From 5364b4f7fbc4c88ab555cb2863c7417790fc02d7 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Mon, 15 Aug 2011 06:56:15 -0400 Subject: [PATCH] fix #3007 (false positive: (style) Struct 'Fred' hides typedef with same name) --- lib/tokenize.cpp | 4 ++++ test/testsimplifytokens.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e9fa933ea..7f1d44a4c 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -725,6 +725,10 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token { return true; } + else if (tok->next()->str() == name->str()) + { + return true; + } else if (tok->next()->str() != ";") { duplicateTypedefError(*tokPtr, name, "Struct"); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 3e322b922..6517e4ceb 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -268,6 +268,7 @@ private: TEST_CASE(simplifyTypedef100); // ticket #3000 TEST_CASE(simplifyTypedef101); // ticket #3003 (segmentation fault) TEST_CASE(simplifyTypedef102); // ticket #3004 + TEST_CASE(simplifyTypedef103); // ticket #3007 TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -5405,6 +5406,17 @@ private: ASSERT_EQUALS("", errout.str()); } + void simplifyTypedef103() // ticket #3007 + { + const char code[] = "typedef struct { } Fred;\n" + "void foo()\n" + "{\n" + " Fred Fred;\n" + "}\n"; + sizeof_(code); + ASSERT_EQUALS("", errout.str()); + } + void simplifyTypedefFunction1() { {