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 @@ -6406,7 +6406,7 @@ void Tokenizer::simplifyVarDecl(Token * tokBegin, const Token * const tokEnd, co
varName = varName->next();
else
--typelen;
if (isCPP() && Token::Match(varName, "public:|private:|protected:"))
if (isCPP() && Token::Match(varName, "public:|private:|protected:|using"))
continue;
//skip all the pointer part
bool isPointerOrRef = false;
Expand Down
32 changes: 21 additions & 11 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1990,18 +1990,28 @@ class TestVarID : public TestFixture {
}

void varid_in_class24() {
const char code[] = "class A {\n"
" Q_OBJECT\n"
"public:\n"
" using QPtr = QPointer<A>;\n"
"};\n";

const char expected[] = "1: class A {\n"
"2: Q_OBJECT\n"
"3: public:\n"
"4:\n"
"5: } ;\n";
const char *code{}, *expected{};

code = "class A {\n"
" Q_OBJECT\n"
"public:\n"
" using QPtr = QPointer<A>;\n"
"};\n";
expected = "1: class A {\n"
"2: Q_OBJECT\n"
"3: public:\n"
"4:\n"
"5: } ;\n";
ASSERT_EQUALS(expected, tokenize(code, "test.cpp"));

code = "class A {\n"
" Q_OBJECT\n"
" using QPtr = QPointer<A>;\n"
"};\n";
expected = "1: class A {\n"
"2: Q_OBJECT\n"
"3:\n"
"4: } ;\n";
ASSERT_EQUALS(expected, tokenize(code, "test.cpp"));
}

Expand Down