File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2295,6 +2295,13 @@ void Tokenizer::simplifyTypedefCpp()
22952295 tok2 = tok2->tokAt (2 );
22962296 else
22972297 tok2 = tok2->tokAt (3 );
2298+ while (tok2->link ()) {
2299+ tok2 = tok2->link ()->next ();
2300+ if (Token::simpleMatch (tok2, " ;" )) {
2301+ tok2 = tok2->previous ();
2302+ break ;
2303+ }
2304+ }
22982305 if (!tok2)
22992306 syntaxError (nullptr );
23002307
Original file line number Diff line number Diff line change @@ -231,6 +231,7 @@ class TestSimplifyTypedef : public TestFixture {
231231 TEST_CASE (simplifyTypedef158);
232232 TEST_CASE (simplifyTypedef159);
233233 TEST_CASE (simplifyTypedef160);
234+ TEST_CASE (simplifyTypedef161);
234235
235236 TEST_CASE (simplifyTypedefFunction1);
236237 TEST_CASE (simplifyTypedefFunction2); // ticket #1685
@@ -3842,6 +3843,22 @@ class TestSimplifyTypedef : public TestFixture {
38423843 ASSERT_EQUALS (exp2, simplifyTypedefC (code2));
38433844 }
38443845
3846+ void simplifyTypedef161 () {
3847+ const char code[] = " namespace N {\n " // #11775
3848+ " typedef int A[3];\n "
3849+ " p = new A*[n];\n "
3850+ " }\n " ;
3851+ const char cur[] = " namespace N { p = new int ( * [ n ] ) [ 3 ] ; }" ;
3852+ const char exp[] = " namespace N { p = new ( int ( * [ n ] ) [ 3 ] ) ; }" ;
3853+ TODO_ASSERT_EQUALS (exp, cur, tok (code));
3854+
3855+ const char code2[] = " typedef int A[3];\n "
3856+ " p = new A*[n];\n " ;
3857+ const char cur2[] = " p = new int ( * ) [ n ] [ 3 ] ;" ;
3858+ const char exp2[] = " p = new ( int ( * [ n ] ) [ 3 ] ) ;" ;
3859+ TODO_ASSERT_EQUALS (exp2, cur2, tok (code2));
3860+ }
3861+
38453862 void simplifyTypedefFunction1 () {
38463863 {
38473864 const char code[] = " typedef void (*my_func)();\n "
You can’t perform that action at this time.
0 commit comments