This commit is contained in:
parent
f2976e5bb5
commit
18b60d2f2b
|
@ -3080,15 +3080,15 @@ bool Tokenizer::simplifyUsing()
|
|||
tok1->deletePrevious();
|
||||
break;
|
||||
} else {
|
||||
const std::string::size_type idx = fullScope.rfind(' ');
|
||||
const std::string::size_type idx = fullScope.rfind("::");
|
||||
|
||||
if (idx == std::string::npos)
|
||||
break;
|
||||
|
||||
if (tok1->strAt(-2) == fullScope.substr(idx + 1)) {
|
||||
if (tok1->strAt(-2) == fullScope.substr(idx + 3)) {
|
||||
tok1->deletePrevious();
|
||||
tok1->deletePrevious();
|
||||
fullScope.resize(idx - 3);
|
||||
fullScope.resize(idx - 1);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
TEST_CASE(simplifyUsing24);
|
||||
TEST_CASE(simplifyUsing25);
|
||||
TEST_CASE(simplifyUsing26); // #11090
|
||||
TEST_CASE(simplifyUsing27);
|
||||
|
||||
TEST_CASE(simplifyUsing8970);
|
||||
TEST_CASE(simplifyUsing8971);
|
||||
|
@ -656,6 +657,24 @@ private:
|
|||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void simplifyUsing27() { // #11670
|
||||
const char code[] = "namespace N {\n"
|
||||
" template <class T>\n"
|
||||
" struct S {\n"
|
||||
" using iterator = T*;\n"
|
||||
" iterator begin();\n"
|
||||
" };\n"
|
||||
"}\n"
|
||||
"using I = N::S<int>;\n"
|
||||
"void f() {\n"
|
||||
" I::iterator iter;\n"
|
||||
"}\n";
|
||||
const char expected[] = "namespace N { struct S<int> ; } "
|
||||
"void f ( ) { int * iter ; } "
|
||||
"struct N :: S<int> { int * begin ( ) ; } ;";
|
||||
ASSERT_EQUALS(expected, tok(code));
|
||||
}
|
||||
|
||||
void simplifyUsing8970() {
|
||||
const char code[] = "using V = std::vector<int>;\n"
|
||||
"struct A {\n"
|
||||
|
|
Loading…
Reference in New Issue