diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d71a2c3f5..cc97f836e 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1812,7 +1812,7 @@ namespace { const ScopeInfo3 * tempScope = this; while (tempScope) { for (const auto & child : tempScope->children) { - if (child.name == scope || child.fullName == scope) + if (child.type == Record && (child.name == scope || child.fullName == scope)) return &child; } diff --git a/test/testsimplifyusing.cpp b/test/testsimplifyusing.cpp index 88d9f68d4..394ae2668 100644 --- a/test/testsimplifyusing.cpp +++ b/test/testsimplifyusing.cpp @@ -974,6 +974,33 @@ private: ASSERT_EQUALS(exp, tok(code, true)); ASSERT_EQUALS("", errout.str()); } + { + const char code[] = "foo::ResultCodes_e\n" + "GemImpl::setR(const ::foo::s _ipSource)\n" + "{\n" + " M3_LOG_EE_DEBUG();\n" + " using MLSource = foo::s::Literal;\n" + " auto ret = foo::ResultCodes_e::NO_ERROR;\n" + " M3_LOG_INFO(\"foo(\" << static_cast(_ipSource) << \")\");\n" + " return ret;\n" + "}\n" + "foo::ResultCodes_e\n" + "GemImpl::getF(::foo::s &_ipSource)\n" + "{\n" + " M3_LOG_EE_DEBUG();\n" + " auto ret = foo::ResultCodes_e::NO_ERROR;\n" + " return ret;\n" + "}\n" + "foo::ResultCodes_e\n" + "GemImpl::setF(const ::foo::s _ipSource)\n" + "{\n" + " M3_LOG_EE_DEBUG();\n" + " using MLSource = foo::s::Literal;\n" + " auto ret = foo::ResultCodes_e::NO_ERROR;\n" + " return ret;\n" + "}"; + tok(code, true); // don't crash + } } void simplifyUsing10171() {