fix #2587 (Spurious warning about struct hiding typedef)
This commit is contained in:
parent
f9b1505115
commit
77fe9858e2
|
@ -837,19 +837,29 @@ static Token *splitDefinitionFromTypedef(Token *tok)
|
||||||
|
|
||||||
tok1->insertToken(";");
|
tok1->insertToken(";");
|
||||||
tok1 = tok1->next();
|
tok1 = tok1->next();
|
||||||
tok1->insertToken("typedef");
|
|
||||||
tok1 = tok1->next();
|
if (tok1->next()->str() == ";" && tok1 && tok1->previous()->str() == "}")
|
||||||
Token * tok3 = tok1;
|
|
||||||
if (isConst)
|
|
||||||
{
|
{
|
||||||
tok1->insertToken("const");
|
tok->deleteThis();
|
||||||
tok1 = tok1->next();
|
tok1->deleteThis();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tok1->insertToken("typedef");
|
||||||
|
tok1 = tok1->next();
|
||||||
|
Token * tok3 = tok1;
|
||||||
|
if (isConst)
|
||||||
|
{
|
||||||
|
tok1->insertToken("const");
|
||||||
|
tok1 = tok1->next();
|
||||||
|
}
|
||||||
|
tok1->insertToken(tok->next()->str()); // struct, union or enum
|
||||||
|
tok1 = tok1->next();
|
||||||
|
tok1->insertToken(name.c_str());
|
||||||
|
tok->deleteThis();
|
||||||
|
tok = tok3;
|
||||||
}
|
}
|
||||||
tok1->insertToken(tok->next()->str()); // struct, union or enum
|
|
||||||
tok1 = tok1->next();
|
|
||||||
tok1->insertToken(name.c_str());
|
|
||||||
tok->deleteThis();
|
|
||||||
tok = tok3;
|
|
||||||
|
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,6 +237,7 @@ private:
|
||||||
TEST_CASE(simplifyTypedef77); // ticket #2554
|
TEST_CASE(simplifyTypedef77); // ticket #2554
|
||||||
TEST_CASE(simplifyTypedef78); // ticket #2568
|
TEST_CASE(simplifyTypedef78); // ticket #2568
|
||||||
TEST_CASE(simplifyTypedef79); // ticket #2348
|
TEST_CASE(simplifyTypedef79); // ticket #2348
|
||||||
|
TEST_CASE(simplifyTypedef80); // ticket #2587
|
||||||
|
|
||||||
TEST_CASE(simplifyTypedefFunction1);
|
TEST_CASE(simplifyTypedefFunction1);
|
||||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||||
|
@ -4876,6 +4877,23 @@ private:
|
||||||
ASSERT_EQUALS(expected, sizeof_(code));
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyTypedef80() // ticket #2587
|
||||||
|
{
|
||||||
|
const char code[] = "typedef struct s { };\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" sizeof(struct s);\n"
|
||||||
|
"};\n";
|
||||||
|
const std::string expected = "struct s { } ; "
|
||||||
|
"void f ( ) { "
|
||||||
|
"sizeof ( struct s ) ; "
|
||||||
|
"} ;";
|
||||||
|
ASSERT_EQUALS(expected, sizeof_(code));
|
||||||
|
|
||||||
|
// Check for output..
|
||||||
|
checkSimplifyTypedef(code);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void simplifyTypedefFunction1()
|
void simplifyTypedefFunction1()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue