Skip to content
Open
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: 4 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5165,8 +5165,10 @@ static Token * matchMemberName(const std::list<std::string> &scope, const Token

// Current scope..
for (auto it = scope.cbegin(); it != scope.cend(); ++it) {
if (scopeIt == scopeInfo.cend() || scopeIt->name != *it)
return nullptr;
if (scopeIt == scopeInfo.cend() || scopeIt->name != *it) {
scopeIt = scopeInfo.cbegin();
break;
}
++scopeIt;
}

Expand Down
9 changes: 9 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class TestVarID : public TestFixture {
TEST_CASE(varid70); // #12660 - function
TEST_CASE(varid71); // #12676 - wrong varid in uninstantiated templated constructor
TEST_CASE(varid72);
TEST_CASE(varid73);
TEST_CASE(varid_for_1);
TEST_CASE(varid_for_2);
TEST_CASE(varid_for_3);
Expand Down Expand Up @@ -1409,6 +1410,14 @@ class TestVarID : public TestFixture {
ASSERT_EQUALS(expected1, tokenize(code1));
}

void varid73() {
const char code[] = "namespace a { int x; };\n"
"namespace b { int x = a::x; };\n";
const char expected[] = "1: namespace a { int x@1 ; } ;\n"
"2: namespace b { int x@2 ; x@2 = a :: x@1 ; } ;\n";
ASSERT_EQUALS(expected, tokenize(code));
}

void varid_for_1() {
const char code[] = "void foo(int a, int b) {\n"
" for (int a=1,b=2;;) {}\n"
Expand Down
Loading