Skip to content

Commit c74eb2a

Browse files
Fix #14386 internalError: VarId set for bool literal with static_assert() (danmar#8110)
1 parent fec7ab7 commit c74eb2a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4256,7 +4256,7 @@ static bool setVarIdParseDeclaration(Token*& tok, const VariableMap& variableMap
42564256
{
42574257
const Token* const tok1 = tok;
42584258
Token* tok2 = tok;
4259-
if (!tok2->isName())
4259+
if (!tok2->isName() || (tok2->tokType() != Token::eType && tok2->tokType() != Token::eName && tok2->tokType() != Token::eKeyword))
42604260
return false;
42614261

42624262
nonneg int typeCount = 0;

test/testvarid.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class TestVarID : public TestFixture {
101101
TEST_CASE(varid69);
102102
TEST_CASE(varid70); // #12660 - function
103103
TEST_CASE(varid71); // #12676 - wrong varid in uninstantiated templated constructor
104+
TEST_CASE(varid72);
104105
TEST_CASE(varid_for_1);
105106
TEST_CASE(varid_for_2);
106107
TEST_CASE(varid_for_3);
@@ -1399,6 +1400,12 @@ class TestVarID : public TestFixture {
13991400
ASSERT_EQUALS(expected, tokenize(code));
14001401
}
14011402

1403+
void varid72() {
1404+
const char code1[] = "static_assert(true && true);\n"; // #14386
1405+
const char expected1[] = "1: static_assert ( true && true ) ;\n";
1406+
ASSERT_EQUALS(expected1, tokenize(code1));
1407+
}
1408+
14021409
void varid_for_1() {
14031410
const char code[] = "void foo(int a, int b) {\n"
14041411
" for (int a=1,b=2;;) {}\n"

0 commit comments

Comments
 (0)