Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,12 @@ namespace {
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, scope, tok, tok->link());
added = true;
}
// inline member function
else if ((scopeInfo->type == ScopeInfo3::Record || scopeInfo->type == ScopeInfo3::Namespace) && tok1 && Token::Match(tok1->tokAt(-1), "%name% (")) {
const std::string scope = scopeInfo->name + "::" + tok1->strAt(-1);
scopeInfo = scopeInfo->addChild(ScopeInfo3::MemberFunction, scope, tok, tok->link());
added = true;
}
}

if (!added)
Expand Down
20 changes: 20 additions & 0 deletions test/testsimplifyusing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class TestSimplifyUsing : public TestFixture {
TEST_CASE(simplifyUsing30);
TEST_CASE(simplifyUsing31);
TEST_CASE(simplifyUsing32);
TEST_CASE(simplifyUsing33);

TEST_CASE(simplifyUsing8970);
TEST_CASE(simplifyUsing8971);
Expand Down Expand Up @@ -793,6 +794,25 @@ class TestSimplifyUsing : public TestFixture {
ASSERT_EQUALS("", errout_str());
}

void simplifyUsing33() { // #13090
const char code[] = "namespace N {\n"
" using T = int;\n"
" T f() { return (T)0; }\n"
"}\n"
"struct S {\n"
" using U = int;\n"
" U g() { return (U)0; }\n"
"};\n";
const char expected[] = "namespace N { "
"int f ( ) { return ( int ) 0 ; } "
"} "
"struct S { "
"int g ( ) { return ( int ) 0 ; } "
"} ;";
ASSERT_EQUALS(expected, tok(code, Platform::Type::Native, /*debugwarnings*/ true));
ASSERT_EQUALS("", errout_str());
}

void simplifyUsing8970() {
const char code[] = "using V = std::vector<int>;\n"
"struct A {\n"
Expand Down