Skip to content

Commit e1aa030

Browse files
Fix #14393 FP syntaxError for anonymous bit field (danmar#8119)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 61a4ae9 commit e1aa030

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/tokenize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8837,6 +8837,8 @@ void Tokenizer::findGarbageCode() const
88378837
if (tok->str() == ";") { // do the counting
88388838
semicolons++;
88398839
} else if (tok->str() == ":") {
8840+
if (tok->strAt(-1) == ",")
8841+
syntaxError(tok);
88408842
colons++;
88418843
} else if (tok->str() == ")") { // skip pairs of ( )
88428844
tok = tok->link();
@@ -8960,8 +8962,6 @@ void Tokenizer::findGarbageCode() const
89608962
syntaxError(tok);
89618963
if (Token::Match(tok, ": [)]=]"))
89628964
syntaxError(tok);
8963-
if (Token::simpleMatch(tok, ", :"))
8964-
syntaxError(tok);
89658965
if (Token::Match(tok, "typedef [,;:]"))
89668966
syntaxError(tok);
89678967
if (Token::Match(tok, "? %assign%"))

test/testtokenize.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7681,6 +7681,8 @@ class TestTokenizer : public TestFixture {
76817681

76827682
ASSERT_NO_THROW(tokenizeAndStringify("enum { E = sizeof(struct { int i; }) };")); // #13249
76837683

7684+
ASSERT_NO_THROW(tokenizeAndStringify("struct S { unsigned u:2, :30; };")); // #14393
7685+
76847686
ignore_errout();
76857687
}
76867688

0 commit comments

Comments
 (0)