File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1446,8 +1446,11 @@ void Tokenizer::simplifyTypedef()
14461446 tok2->insertToken (" &" );
14471447 tok2 = tok2->next ();
14481448
1449+ bool hasName = false ;
14491450 // skip over name
1450- if (tok2->next () && tok2->next ()->str () != " )" ) {
1451+ if (tok2->next () && tok2->next ()->str () != " )" && tok2->next ()->str () != " ," &&
1452+ tok2->next ()->str () != " >" ) {
1453+ hasName = true ;
14511454 if (tok2->next ()->str () != " (" )
14521455 tok2 = tok2->next ();
14531456
@@ -1458,12 +1461,13 @@ void Tokenizer::simplifyTypedef()
14581461 // check for array
14591462 if (tok2 && tok2->next () && tok2->next ()->str () == " [" )
14601463 tok2 = tok2->next ()->link ();
1461- } else {
1462- // syntax error
14631464 }
14641465
14651466 tok2->insertToken (" )" );
14661467 Token::createMutualLinks (tok2->next (), tok3);
1468+
1469+ if (!hasName)
1470+ tok2 = tok2->next ();
14671471 } else if (ptrMember) {
14681472 if (Token::simpleMatch (tok2, " * (" )) {
14691473 tok2->insertToken (" *" );
Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ class TestSimplifyTypedef : public TestFixture {
165165 TEST_CASE (simplifyTypedef127); // ticket #8878
166166 TEST_CASE (simplifyTypedef128); // ticket #9053
167167 TEST_CASE (simplifyTypedef129);
168+ TEST_CASE (simplifyTypedef130); // ticket #9446
168169
169170 TEST_CASE (simplifyTypedefFunction1);
170171 TEST_CASE (simplifyTypedefFunction2); // ticket #1685
@@ -2602,6 +2603,19 @@ class TestSimplifyTypedef : public TestFixture {
26022603 }
26032604 }
26042605
2606+ void simplifyTypedef130 () { // #9446
2607+ const char code[] = " template <class, class> void a() {\n "
2608+ " typedef int(*b)[10];\n "
2609+ " a<b, b>();\n "
2610+ " }" ;
2611+
2612+ const char exp [] = " template < class , class > void a ( ) { "
2613+ " a < int ( * ) [ 10 ] , int ( * ) [ 10 ] > ( ) ; "
2614+ " }" ;
2615+
2616+ ASSERT_EQUALS (exp, tok (code, false ));
2617+ }
2618+
26052619 void simplifyTypedefFunction1 () {
26062620 {
26072621 const char code[] = " typedef void (*my_func)();\n "
You can’t perform that action at this time.
0 commit comments