Skip to content

Commit bc2ffd3

Browse files
committed
Fix #13249 FP syntaxError with sizeof in enum
1 parent 17a10d0 commit bc2ffd3

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/tokenize.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -8619,6 +8619,10 @@ void Tokenizer::findGarbageCode() const
86198619
syntaxError(tok->tokAt(2), "Unexpected token '" + tok->strAt(2) + "'");
86208620
if (const Token* start = SymbolDatabase::isEnumDefinition(tok)) {
86218621
for (const Token* tok2 = start->next(); tok2 && tok2 != start->link(); tok2 = tok2->next()) {
8622+
if (Token::simpleMatch(tok2, "sizeof (")) {
8623+
tok2 = tok2->linkAt(1);
8624+
continue;
8625+
}
86228626
if (tok2->str() == ";")
86238627
syntaxError(tok2);
86248628
}

test/testtokenize.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -7216,6 +7216,8 @@ class TestTokenizer : public TestFixture {
72167216
ASSERT_NO_THROW(tokenizeAndStringify("class A { bool restrict() const; };\n"
72177217
"bool A::restrict() const { return true; }")); // #12718
72187218

7219+
ASSERT_NO_THROW(tokenizeAndStringify("enum { E = sizeof(struct { int i; }) };")); // #13249
7220+
72197221
ignore_errout();
72207222
}
72217223

0 commit comments

Comments
 (0)