Skip to content

Commit a182aa8

Browse files
Fix #12625 internalError with function typedefs (#6431)
1 parent 3983c0c commit a182aa8

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ const Token *Tokenizer::processFunc(const Token *tok2, bool inOperator) const
517517
tok2 = tok2->next();
518518

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

523523
// skip over namespace

test/testsimplifytypedef.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class TestSimplifyTypedef : public TestFixture {
5656
TEST_CASE(cfunction1);
5757
TEST_CASE(cfunction2);
5858
TEST_CASE(cfunction3);
59+
TEST_CASE(cfunction4);
5960
TEST_CASE(cfp1);
6061
TEST_CASE(cfp2);
6162
TEST_CASE(cfp4);
@@ -415,6 +416,12 @@ class TestSimplifyTypedef : public TestFixture {
415416
ASSERT_EQUALS("[file.c:2]: (portability) It is unspecified behavior to const qualify a function type.\n", errout_str());
416417
}
417418

419+
void cfunction4() {
420+
const char code[] = "typedef int (func_t) (int);\n" // #12625
421+
"int f(int*, func_t*, int);\n";
422+
ASSERT_EQUALS("int f ( int * , int ( * ) ( int ) , int ) ;", simplifyTypedefC(code));
423+
}
424+
418425
void cfp1() {
419426
const char code[] = "typedef void (*fp)(void * p);\n"
420427
"fp x;";

0 commit comments

Comments
 (0)