Fixed #2341 (false positive for function pointer returning typedef)

This commit is contained in:
Robert Reif 2010-12-22 18:37:23 +01:00 committed by Daniel Marjamäki
parent 00e9822cb3
commit fc7e2d1ac1
2 changed files with 10 additions and 1 deletions

View File

@ -573,7 +573,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
if (Token::Match(tok->previous(), "typedef|}|>") ||
(tok->previous()->str() == "*" && tok->next()->str() != "(") ||
(Token::Match(tok->previous(), "%type%") &&
(!Token::Match(tok->previous(), "return|new|const|friend|public|private|protected|throw") &&
(!Token::Match(tok->previous(), "return|new|const|friend|public|private|protected|throw|extern") &&
!Token::Match(tok->tokAt(-2), "friend class"))))
{
// scan backwards for the end of the previous statement

View File

@ -222,6 +222,7 @@ private:
TEST_CASE(simplifyTypedef63); // ticket #2175 'typedef float x[3];'
TEST_CASE(simplifyTypedef64);
TEST_CASE(simplifyTypedef65); // ticket #2314
TEST_CASE(simplifyTypedef66); // ticket #2341
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -4602,6 +4603,14 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef66() // ticket #2341
{
const char code[] = "typedef long* GEN;\n"
"extern GEN (*foo)(long);";
const std::string actual(sizeof_(code));
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1()
{
{