diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a01f6fb2a..fd01220ba 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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")))) diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index c56cc3571..93fbfa128 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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()