Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2249,6 +2249,8 @@ void Tokenizer::simplifyTypedefCpp()
tok2 = tok3->tokAt(3);
else if (Token::Match(tok2->tokAt(3), "[(),;]"))
tok2 = tok2->tokAt(2);
else if (Token::simpleMatch(tok2->tokAt(3), ">"))
tok2 = tok2->tokAt(2);
else
tok2 = tok2->tokAt(3);
if (!tok2)
Expand Down
13 changes: 13 additions & 0 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class TestSimplifyTypedef : public TestFixture {
TEST_CASE(simplifyTypedef148);
TEST_CASE(simplifyTypedef149);
TEST_CASE(simplifyTypedef150);
TEST_CASE(simplifyTypedef151);

TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
Expand Down Expand Up @@ -3530,6 +3531,18 @@ class TestSimplifyTypedef : public TestFixture {
ASSERT_EQUALS(exp, tok(code));
}

void simplifyTypedef151() {
const char* code{}, *exp{};
code = "namespace N {\n" // #12597
" typedef int T[10];\n"
" const T* f() { return static_cast<const T*>(nullptr); }\n"
"}\n";
exp = "namespace N { "
"const int ( * f ( ) ) [ 10 ] { return static_cast < const int ( * ) [ 10 ] > ( nullptr ) ; } "
"}";
ASSERT_EQUALS(exp, tok(code));
}

void simplifyTypedefFunction1() {
{
const char code[] = "typedef void (*my_func)();\n"
Expand Down