File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -3080,15 +3080,15 @@ bool Tokenizer::simplifyUsing()
30803080 tok1->deletePrevious ();
30813081 break ;
30823082 } else {
3083- const std::string::size_type idx = fullScope.rfind (' ' );
3083+ const std::string::size_type idx = fullScope.rfind (" :: " );
30843084
30853085 if (idx == std::string::npos)
30863086 break ;
30873087
3088- if (tok1->strAt (-2 ) == fullScope.substr (idx + 1 )) {
3088+ if (tok1->strAt (-2 ) == fullScope.substr (idx + 3 )) {
30893089 tok1->deletePrevious ();
30903090 tok1->deletePrevious ();
3091- fullScope.resize (idx - 3 );
3091+ fullScope.resize (idx - 1 );
30923092 } else
30933093 break ;
30943094 }
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ class TestSimplifyUsing : public TestFixture {
7171 TEST_CASE (simplifyUsing24);
7272 TEST_CASE (simplifyUsing25);
7373 TEST_CASE (simplifyUsing26); // #11090
74+ TEST_CASE (simplifyUsing27);
7475
7576 TEST_CASE (simplifyUsing8970);
7677 TEST_CASE (simplifyUsing8971);
@@ -656,6 +657,24 @@ class TestSimplifyUsing : public TestFixture {
656657 ASSERT_EQUALS (expected, tok (code));
657658 }
658659
660+ void simplifyUsing27 () { // #11670
661+ const char code[] = " namespace N {\n "
662+ " template <class T>\n "
663+ " struct S {\n "
664+ " using iterator = T*;\n "
665+ " iterator begin();\n "
666+ " };\n "
667+ " }\n "
668+ " using I = N::S<int>;\n "
669+ " void f() {\n "
670+ " I::iterator iter;\n "
671+ " }\n " ;
672+ const char expected[] = " namespace N { struct S<int> ; } "
673+ " void f ( ) { int * iter ; } "
674+ " struct N :: S<int> { int * begin ( ) ; } ;" ;
675+ ASSERT_EQUALS (expected, tok (code));
676+ }
677+
659678 void simplifyUsing8970 () {
660679 const char code[] = " using V = std::vector<int>;\n "
661680 " struct A {\n "
You can’t perform that action at this time.
0 commit comments