Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static bool isClassStructUnionEnumStart(const Token * tok)
if (!Token::Match(tok->previous(), "class|struct|union|enum|%name%|>|>> {"))
return false;
const Token * tok2 = tok->previous();
while (tok2 && !Token::Match(tok2, "class|struct|union|enum|{|}|)|;|>|>>"))
while (tok2 && !Token::Match(tok2, "class|struct|union|enum|{|}|)|;"))
tok2 = tok2->previous();
return Token::Match(tok2, "class|struct|union|enum") && !Token::simpleMatch(tok2->tokAt(-1), "->");
}
Expand Down
23 changes: 23 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class TestVarID : public TestFixture {
TEST_CASE(varid_in_class26);
TEST_CASE(varid_in_class27);
TEST_CASE(varid_in_class28);
TEST_CASE(varid_in_class29);
TEST_CASE(varid_namespace_1); // #7272
TEST_CASE(varid_namespace_2); // #7000
TEST_CASE(varid_namespace_3); // #8627
Expand Down Expand Up @@ -2380,6 +2381,28 @@ class TestVarID : public TestFixture {
ASSERT_EQUALS(expected, tokenize(code));
}

void varid_in_class29() {
const char code[] = "struct S {\n" // #14486
" const int& r;\n"
" explicit S(const int& r) : r(r) {}\n"
" static void f() {\n"
" struct T : std::vector<int> {\n"
" bool g() const { return empty(); }\n"
" };\n"
" }\n"
"};\n";
const char expected[] = "1: struct S {\n"
"2: const int & r@1 ;\n"
"3: explicit S ( const int & r@2 ) : r@1 ( r@2 ) { }\n"
"4: static void f ( ) {\n"
"5: struct T : std :: vector < int > {\n"
"6: bool g ( ) const { return empty ( ) ; }\n"
"7: } ;\n"
"8: }\n"
"9: } ;\n";
ASSERT_EQUALS(expected, tokenize(code));
}

void varid_namespace_1() { // #7272
const char code[] = "namespace Blah {\n"
" struct foo { int x;};\n"
Expand Down
Loading