fix #3000 (false positive: (style) Struct 'Fred' hides typedef with same name)

This commit is contained in:
Robert Reif 2011-08-14 18:50:33 -04:00
parent 389ab80b63
commit b7f42535ec
2 changed files with 17 additions and 0 deletions

View File

@ -721,6 +721,10 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
duplicateTypedefError(*tokPtr, name, "Struct");
return true;
}
else if (tok->next()->str() == ")")
{
return true;
}
else if (tok->next()->str() != ";")
{
duplicateTypedefError(*tokPtr, name, "Struct");

View File

@ -265,6 +265,7 @@ private:
TEST_CASE(simplifyTypedef97); // ticket #2983 (segmentation fault)
TEST_CASE(simplifyTypedef98); // ticket #2963
TEST_CASE(simplifyTypedef99); // ticket #2999
TEST_CASE(simplifyTypedef100); // ticket #3000
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -5371,6 +5372,18 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef100() // ticket #3000
{
const char code[] = "typedef struct Fred { } Fred;\n"
"Fred * foo() {\n"
" Fred *fred;\n"
" fred = se_alloc(sizeof(struct Fred));\n"
" return fred;\n"
"}\n";
sizeof_(code);
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1()
{
{