Fixed #1801 (simplifyTypedef: duplicate typedefs not handled properly)
This commit is contained in:
parent
0c61454b3f
commit
ec61c6fa26
|
@ -548,7 +548,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name)
|
|||
else
|
||||
{
|
||||
// look backwards
|
||||
if (Token::Match(tok->previous(), "typedef|}|>") ||
|
||||
if (Token::Match(tok->previous(), "typedef|}|>|*") ||
|
||||
(Token::Match(tok->previous(), "%type%") &&
|
||||
(!Token::Match(tok->previous(), "return|new|const|friend|public|private|protected") &&
|
||||
!Token::Match(tok->tokAt(-2), "friend class"))))
|
||||
|
|
|
@ -4189,6 +4189,21 @@ private:
|
|||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "typedef int (*PPDMarkOption)(ppd_file_t *ppd, const char *keyword, const char *option);\n"
|
||||
"typedef int (*PPDMarkOption)(ppd_file_t *ppd, const char *keyword, const char *option);\n";
|
||||
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Typedef 'PPDMarkOption' hides typedef with same name\n", errout.str());
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "typedef int * A;\n"
|
||||
"typedef int * A;\n";
|
||||
checkSimplifyTypedef(code);
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:1]: (style) Typedef 'A' hides typedef with same name\n", errout.str());
|
||||
}
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1()
|
||||
|
|
Loading…
Reference in New Issue