Skip to content

Commit 71437f2

Browse files
Fix #15070 FP syntaxError on bit field with initializer (cppcheck-opensource#8901)
1 parent fa6c1f1 commit 71437f2

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎lib/tokenize.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9116,7 +9116,8 @@ void Tokenizer::findGarbageCode() const
91169116
if (tok->strAt(1) == "(")
91179117
syntaxError(tok);
91189118
else if (!(tok->tokType() == Token::Type::eString && Token::simpleMatch(tok->tokAt(-1), "extern")) &&
9119-
!(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires")))
9119+
!(tok->tokType() == Token::Type::eBoolean && cpp && Token::simpleMatch(tok->tokAt(-1), "requires")) &&
9120+
!Token::simpleMatch(tok->linkAt(1), "} ;"))
91209121
syntaxError(tok);
91219122
}
91229123
if (Token::Match(tok, "( ) %num%|%bool%|%char%|%str%"))

‎test/testtokenize.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8138,6 +8138,7 @@ class TestTokenizer : public TestFixture {
81388138
ignore_errout();
81398139

81408140
ASSERT_EQUALS(";", tokenizeAndStringify("typedef std::size_t size_t;\n")); // #14809
8141+
ASSERT_EQUALS("struct S { int i { 0 } ; } ;", tokenizeAndStringify("struct S { int i : 1{0}; };\n")); // #15070
81418142
}
81428143

81438144

0 commit comments

Comments
 (0)