From d88e67c0f10fa23c9db361fc6a6c65953df20580 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 27 May 2026 09:31:01 +0200 Subject: [PATCH 1/2] Update testsimplifytypedef.cpp --- test/testsimplifytypedef.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 342cda59dc8..022412139f1 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -231,6 +231,7 @@ class TestSimplifyTypedef : public TestFixture { TEST_CASE(simplifyTypedef158); TEST_CASE(simplifyTypedef159); TEST_CASE(simplifyTypedef160); + TEST_CASE(simplifyTypedef161); TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -3842,6 +3843,22 @@ class TestSimplifyTypedef : public TestFixture { ASSERT_EQUALS(exp2, simplifyTypedefC(code2)); } + void simplifyTypedef161() { + const char code[] = "namespace N {\n" // #11775 + " typedef int A[3];\n" + " p = new A*[n];\n" + "}\n"; + const char cur[] = "namespace N { p = new int ( * [ n ] ) [ 3 ] ; }"; + const char exp[] = "namespace N { p = new ( int ( * [ n ] ) [ 3 ] ) ; }"; + TODO_ASSERT_EQUALS(exp, cur, tok(code)); + + const char code2[] = "typedef int A[3];\n" + "p = new A*[n];\n"; + const char cur2[] = "p = new int ( * ) [ n ] [ 3 ] ;"; + const char exp2[] = "p = new ( int ( * [ n ] ) [ 3 ] ) ;"; + TODO_ASSERT_EQUALS(exp2, cur2, tok(code2)); + } + void simplifyTypedefFunction1() { { const char code[] = "typedef void (*my_func)();\n" From 4ed966a0a2dfdd590a5eff3f3fcc18fee24c282b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 27 May 2026 09:32:54 +0200 Subject: [PATCH 2/2] Update tokenize.cpp --- lib/tokenize.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 6f9cf90a852..6305e0f021a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2295,6 +2295,13 @@ void Tokenizer::simplifyTypedefCpp() tok2 = tok2->tokAt(2); else tok2 = tok2->tokAt(3); + while (tok2->link()) { + tok2 = tok2->link()->next(); + if (Token::simpleMatch(tok2, ";")) { + tok2 = tok2->previous(); + break; + } + } if (!tok2) syntaxError(nullptr);