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 @@ -4254,7 +4254,7 @@ static bool setVarIdParseDeclaration(Token*& tok, const VariableMap& variableMap
{
const Token* const tok1 = tok;
Token* tok2 = tok;
if (!tok2->isName())
if (!tok2->isName() || (tok2->tokType() != Token::eType && tok2->tokType() != Token::eName && tok2->tokType() != Token::eKeyword))
return false;

nonneg int typeCount = 0;
Expand Down
7 changes: 7 additions & 0 deletions test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class TestVarID : public TestFixture {
TEST_CASE(varid69);
TEST_CASE(varid70); // #12660 - function
TEST_CASE(varid71); // #12676 - wrong varid in uninstantiated templated constructor
TEST_CASE(varid72);
TEST_CASE(varid_for_1);
TEST_CASE(varid_for_2);
TEST_CASE(varid_for_3);
Expand Down Expand Up @@ -1399,6 +1400,12 @@ class TestVarID : public TestFixture {
ASSERT_EQUALS(expected, tokenize(code));
}

void varid72() {
const char code1[] = "static_assert(true && true);\n"; // #14386
const char expected1[] = "1: static_assert ( true && true ) ;\n";
ASSERT_EQUALS(expected1, tokenize(code1));
}

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