Skip to content

Commit

Permalink
Fix #12625 internalError with function typedefs (#6431)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed May 23, 2024
1 parent 3983c0c commit a182aa8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ const Token *Tokenizer::processFunc(const Token *tok2, bool inOperator) const
tok2 = tok2->next();

while (Token::Match(tok2, "*|&") &&
!Token::Match(tok2->next(), ")|>"))
!Token::Match(tok2->next(), "[)>,]"))
tok2 = tok2->next();

// skip over namespace
Expand Down
7 changes: 7 additions & 0 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TestSimplifyTypedef : public TestFixture {
TEST_CASE(cfunction1);
TEST_CASE(cfunction2);
TEST_CASE(cfunction3);
TEST_CASE(cfunction4);
TEST_CASE(cfp1);
TEST_CASE(cfp2);
TEST_CASE(cfp4);
Expand Down Expand Up @@ -415,6 +416,12 @@ class TestSimplifyTypedef : public TestFixture {
ASSERT_EQUALS("[file.c:2]: (portability) It is unspecified behavior to const qualify a function type.\n", errout_str());
}

void cfunction4() {
const char code[] = "typedef int (func_t) (int);\n" // #12625
"int f(int*, func_t*, int);\n";
ASSERT_EQUALS("int f ( int * , int ( * ) ( int ) , int ) ;", simplifyTypedefC(code));
}

void cfp1() {
const char code[] = "typedef void (*fp)(void * p);\n"
"fp x;";
Expand Down

0 comments on commit a182aa8

Please sign in to comment.