Fixed #2341 (false positive for function pointer returning typedef)
This commit is contained in:
parent
00e9822cb3
commit
fc7e2d1ac1
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue