Skip to content

Commit 4b0c239

Browse files
authored
Fix #14017: Missing varid on namespace member (#8784)
1 parent 1444269 commit 4b0c239

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

lib/tokenize.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5172,8 +5172,10 @@ static Token * matchMemberName(const std::list<std::string> &scope, const Token
51725172

51735173
// Current scope..
51745174
for (auto it = scope.cbegin(); it != scope.cend(); ++it) {
5175-
if (scopeIt == scopeInfo.cend() || scopeIt->name != *it)
5176-
return nullptr;
5175+
if (scopeIt == scopeInfo.cend() || scopeIt->name != *it) {
5176+
scopeIt = scopeInfo.cbegin();
5177+
break;
5178+
}
51775179
++scopeIt;
51785180
}
51795181

test/testvarid.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class TestVarID : public TestFixture {
102102
TEST_CASE(varid70); // #12660 - function
103103
TEST_CASE(varid71); // #12676 - wrong varid in uninstantiated templated constructor
104104
TEST_CASE(varid72);
105+
TEST_CASE(varid73);
105106
TEST_CASE(varid_for_1);
106107
TEST_CASE(varid_for_2);
107108
TEST_CASE(varid_for_3);
@@ -1409,6 +1410,14 @@ class TestVarID : public TestFixture {
14091410
ASSERT_EQUALS(expected1, tokenize(code1));
14101411
}
14111412

1413+
void varid73() {
1414+
const char code[] = "namespace a { int x; };\n"
1415+
"namespace b { int x = a::x; };\n";
1416+
const char expected[] = "1: namespace a { int x@1 ; } ;\n"
1417+
"2: namespace b { int x@2 ; x@2 = a :: x@1 ; } ;\n";
1418+
ASSERT_EQUALS(expected, tokenize(code));
1419+
}
1420+
14121421
void varid_for_1() {
14131422
const char code[] = "void foo(int a, int b) {\n"
14141423
" for (int a=1,b=2;;) {}\n"

0 commit comments

Comments
 (0)