Fix #9381 (alias in namespace not replaced in method declaration) (#2232)

This commit is contained in:
IOBYTE 2019-10-02 02:11:04 -04:00 committed by amai2012
parent 87ece5856a
commit 4ba00d0694
2 changed files with 26 additions and 0 deletions

View File

@ -1855,6 +1855,7 @@ namespace {
std::string newScope1 = scope1;
// scopes didn't match so try higher scopes
index = newScope1.size();
while (!newScope1.empty()) {
std::string::size_type separator = newScope1.rfind(" :: ", index - 1);
if (separator != std::string::npos)

View File

@ -65,6 +65,7 @@ private:
TEST_CASE(simplifyUsing9040);
TEST_CASE(simplifyUsing9042);
TEST_CASE(simplifyUsing9191);
TEST_CASE(simplifyUsing9381);
}
std::string tok(const char code[], bool simplify = true, Settings::PlatformType type = Settings::Native, bool debugwarnings = true) {
@ -524,6 +525,30 @@ private:
ASSERT_EQUALS(exp, tok(code, false));
}
void simplifyUsing9381() {
const char code[] = "namespace ns {\n"
" class Result;\n"
" using UniqueResultPtr = std::unique_ptr<Result>;\n"
" class A {\n"
" public:\n"
" void func(UniqueResultPtr);\n"
" };\n"
" void A::func(UniqueResultPtr) {\n"
" }\n"
"}";
const char exp[] = "namespace ns { "
"class Result ; "
"class A { "
"public: "
"void func ( std :: unique_ptr < Result > ) ; "
"} ; "
"void A :: func ( std :: unique_ptr < Result > ) { "
"} "
"}";
ASSERT_EQUALS(exp, tok(code, false));
}
};
REGISTER_TEST(TestSimplifyUsing)