File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -3343,9 +3343,12 @@ bool Tokenizer::simplifyUsing()
33433343 // function pointer
33443344 TokenList::copyTokens (tok1->next (), fpArgList, usingEnd->previous ());
33453345 Token* const copyEnd = TokenList::copyTokens (tok1, start, fpQual->link ()->previous ());
3346- tok1->deleteThis ();
3346+ Token* leftPar = copyEnd->previous ();
3347+ while (leftPar->str () != " (" )
3348+ leftPar = leftPar->previous ();
33473349 Token* const rightPar = copyEnd->next ()->insertToken (" )" );
3348- Token::createMutualLinks (tok1->next (), rightPar);
3350+ Token::createMutualLinks (leftPar, rightPar);
3351+ tok1->deleteThis ();
33493352 substitute = true ;
33503353 } else if (fpArgList && !fpQual && Token::Match (tok1->next (), " * const| %name%" )) {
33513354 // function pointer
Original file line number Diff line number Diff line change @@ -898,6 +898,14 @@ class TestSimplifyUsing : public TestFixture {
898898 const char expected2[] = " int ( * fp1 ) ( int ) ; int ( * const fp2 ) ( int ) ;" ;
899899 ASSERT_EQUALS (expected2, tok (code2));
900900 ASSERT_EQUALS (" " , errout_str ());
901+
902+ const char code3[] = " using FP = std::string (*)();\n "
903+ " using FPC = std::string (*const)();\n "
904+ " FP fp;\n "
905+ " FPC fpc{};\n " ;
906+ const char expected3[] = " std :: string ( * fp ) ( ) ; std :: string ( * const fpc ) ( ) { } ;" ;
907+ ASSERT_EQUALS (expected3, tok (code3));
908+ ASSERT_EQUALS (" " , errout_str ());
901909 }
902910
903911 void simplifyUsing8970 () {
You can’t perform that action at this time.
0 commit comments