From c3ea923a89d277c19830761f2f586f207d50ad53 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:53:05 +0200 Subject: [PATCH 1/2] Update tokenize.cpp --- lib/tokenize.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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) From 03b6e7f7014588b452f5472b7b77b3ec03ffb004 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:59:28 +0200 Subject: [PATCH 2/2] Update testsimplifyusing.cpp --- test/testsimplifyusing.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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"