File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -858,6 +858,8 @@ namespace {
858858 // Function return type => replace array with "*"
859859 for (const Token* a = mRangeAfterVar .first ; Token::simpleMatch (a, " [" ); a = a->link ()->next ())
860860 tok3->insertToken (" *" );
861+ } else if (Token::Match (after->previous (), " %name% ( * %name% ) [" )) {
862+ after = after->linkAt (4 )->next ();
861863 } else {
862864 Token* prev = after->previous ();
863865 if (prev->isName () && prev != tok3)
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ class TestSimplifyTypedef : public TestFixture {
6868 TEST_CASE (cfp7);
6969 TEST_CASE (carray1);
7070 TEST_CASE (carray2);
71+ TEST_CASE (carray3);
7172 TEST_CASE (cdonotreplace1);
7273 TEST_CASE (cppfp1);
7374 TEST_CASE (Generic1);
@@ -458,6 +459,20 @@ class TestSimplifyTypedef : public TestFixture {
458459 ASSERT_EQUALS (" double x [ 10 ] [ 4 ] ;" , simplifyTypedef (code));
459460 }
460461
462+ void carray3 () {
463+ const char * code{};
464+ code = " typedef int a[256];\n " // #11689
465+ " typedef a b[256];\n "
466+ " b* p;\n " ;
467+ ASSERT_EQUALS (" int ( * p ) [ 256 ] [ 256 ] ;" , simplifyTypedef (code));
468+
469+ code = " typedef int a[1];\n "
470+ " typedef a b[2];\n "
471+ " typedef b c[3];\n "
472+ " c* p;\n " ;
473+ ASSERT_EQUALS (" int ( * p ) [ 3 ] [ 2 ] [ 1 ] ;" , simplifyTypedef (code));
474+ }
475+
461476 void cdonotreplace1 () {
462477 const char code[] = " typedef int t;\n "
463478 " int* t;" ;
You can’t perform that action at this time.
0 commit comments