diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index fb6b7c1b867..c59737072d3 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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) diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 0c0e52f0aea..32ce460db3e 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -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); @@ -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;\n" "struct A {\n"