From 995a766f17e37ad938a6803582b255acc04a7488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 16 Apr 2026 12:29:00 +0200 Subject: [PATCH 1/3] add test for #10343 --- test/testsimplifytypedef.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 03ac9b45a9e..1ce373fb7d9 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -243,6 +243,7 @@ class TestSimplifyTypedef : public TestFixture { TEST_CASE(simplifyTypedefFunction9); TEST_CASE(simplifyTypedefFunction10); // #5191 TEST_CASE(simplifyTypedefFunction11); + TEST_CASE(simplifyTypedefFunction12); TEST_CASE(simplifyTypedefStruct); // #12081 - volatile struct @@ -4444,6 +4445,15 @@ class TestSimplifyTypedef : public TestFixture { ignore_errout(); // we are not interested in the output } + void simplifyTypedefFunction12() { + const char code[] = "typedef (*pfi)(void);\n" + "pfi f;\n"; + + const char expected[] = "int ( * f ) ( void ) ;"; + ASSERT_EQUALS(expected, tok(code, dinit(TokOptions, $.debugwarnings = false))); + ASSERT_EQUALS("", errout_str()); + } + void simplifyTypedefStruct() { const char code1[] = "typedef struct S { int x; } xyz;\n" "xyz var;"; From 2d9a26f520630a15f7d7498278bf852c571da2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 16 Apr 2026 12:35:15 +0200 Subject: [PATCH 2/3] add test for #14604 --- test/testsimplifytypedef.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 1ce373fb7d9..22cad3948d9 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -262,6 +262,7 @@ class TestSimplifyTypedef : public TestFixture { TEST_CASE(typedefInfo2); TEST_CASE(typedefInfo3); TEST_CASE(typedefInfo4); + TEST_CASE(typedefInfo5); } class TokenizerTest final : public Tokenizer @@ -4683,6 +4684,23 @@ class TestSimplifyTypedef : public TestFixture { " \n" " \n", xml); } + + void typedefInfo5() { + const std::string xml = dumpTypedefInfo("typedef (*pfi)(void);\n"); + ASSERT_EQUALS(" \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n", xml); + } }; REGISTER_TEST(TestSimplifyTypedef) From 549935ec2cf38fb732e01c53bd90651c006b03ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Thu, 16 Apr 2026 12:20:31 +0200 Subject: [PATCH 3/3] fix --- lib/tokenize.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 40dbdf88f9d..c472522a6f2 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1042,6 +1042,9 @@ void Tokenizer::simplifyTypedef() std::map> numberOfTypedefs; for (Token* tok = list.front(); tok; tok = tok->next()) { if (tok->str() == "typedef") { + if (Token::simpleMatch(tok, "typedef ( *") && Token::simpleMatch(tok->linkAt(1), ") (")) + // Implicit return type + tok->insertToken("int"); TypedefSimplifier ts(tok); if (ts.fail() || !ts.nameToken()) continue;