Skip to content

Commit d3d2e16

Browse files
IOBYTERobert Reif
andauthored
fix hang from f48e195 (fix #10136 TODO test (cppcheck-opensource#3117)) (cppcheck-opensource#3120)
Co-authored-by: Robert Reif <reif@FX6840>
1 parent 25fa7c5 commit d3d2e16

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ namespace {
18121812
const ScopeInfo3 * tempScope = this;
18131813
while (tempScope) {
18141814
for (const auto & child : tempScope->children) {
1815-
if (child.name == scope || child.fullName == scope)
1815+
if (child.type == Record && (child.name == scope || child.fullName == scope))
18161816
return &child;
18171817
}
18181818

test/testsimplifyusing.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,33 @@ class TestSimplifyUsing : public TestFixture {
974974
ASSERT_EQUALS(exp, tok(code, true));
975975
ASSERT_EQUALS("", errout.str());
976976
}
977+
{
978+
const char code[] = "foo::ResultCodes_e\n"
979+
"GemImpl::setR(const ::foo::s _ipSource)\n"
980+
"{\n"
981+
" M3_LOG_EE_DEBUG();\n"
982+
" using MLSource = foo::s::Literal;\n"
983+
" auto ret = foo::ResultCodes_e::NO_ERROR;\n"
984+
" M3_LOG_INFO(\"foo(\" << static_cast<int>(_ipSource) << \")\");\n"
985+
" return ret;\n"
986+
"}\n"
987+
"foo::ResultCodes_e\n"
988+
"GemImpl::getF(::foo::s &_ipSource)\n"
989+
"{\n"
990+
" M3_LOG_EE_DEBUG();\n"
991+
" auto ret = foo::ResultCodes_e::NO_ERROR;\n"
992+
" return ret;\n"
993+
"}\n"
994+
"foo::ResultCodes_e\n"
995+
"GemImpl::setF(const ::foo::s _ipSource)\n"
996+
"{\n"
997+
" M3_LOG_EE_DEBUG();\n"
998+
" using MLSource = foo::s::Literal;\n"
999+
" auto ret = foo::ResultCodes_e::NO_ERROR;\n"
1000+
" return ret;\n"
1001+
"}";
1002+
tok(code, true); // don't crash
1003+
}
9771004
}
9781005

9791006
void simplifyUsing10171() {

0 commit comments

Comments
 (0)