fix hang in simplifyUsing (#3128)

Co-authored-by: Robert Reif <reif@FX6840>
This commit is contained in:
IOBYTE 2021-02-12 10:21:51 -05:00 committed by GitHub
parent e57a674458
commit 1eafed9e75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 22 deletions

View File

@ -2293,7 +2293,8 @@ bool Tokenizer::simplifyUsing()
// We can limit the search to the current function when the type alias
// is defined in that function.
if (currentScope->type == ScopeInfo3::Other) {
if (currentScope->type == ScopeInfo3::Other ||
currentScope->type == ScopeInfo3::MemberFunction) {
scopeInfo1 = scopeInfo;
currentScope1 = scopeInfo.findScope(currentScope);
if (!currentScope1)

View File

@ -1103,6 +1103,7 @@ private:
}
void simplifyUsing10173() {
{
const char code[] = "std::ostream & operator<<(std::ostream &s, const Pr<st> p) {\n"
" return s;\n"
"}\n"
@ -1125,6 +1126,29 @@ private:
ASSERT_EQUALS(exp, tok(code, true));
ASSERT_EQUALS("", errout.str());
}
{
const char code[] = "namespace defsa {\n"
"void xxx::foo() {\n"
" using NS1 = v1::l;\n"
"}\n"
"void xxx::bar() {\n"
" using NS1 = v1::l;\n"
"}\n"
"void xxx::foobar() {\n"
" using NS1 = v1::l;\n"
"}\n"
"}";
const char exp[] = "namespace defsa { "
"void xxx :: foo ( ) { "
"} "
"void xxx :: bar ( ) { "
"} "
"void xxx :: foobar ( ) { "
"} "
"}";
ASSERT_EQUALS(exp, tok(code, true));
}
}
};
REGISTER_TEST(TestSimplifyUsing)