Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Apr 3, 2024
1 parent ce4afd2 commit 064fd52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8610,11 +8610,11 @@ void Tokenizer::findGarbageCode() const
syntaxError(tok);
if (Token::Match(tok, "%assign% typename|class %assign%"))
syntaxError(tok);
if (Token::Match(tok, "%assign% [;)}]"))
if (Token::Match(tok, "%assign% [;)}]") && (!isCPP() || !Token::Match(tok->previous(), "operator %assign% ;")))
syntaxError(tok);
if (Token::Match(tok, "%cop%|=|,|[ %or%|%oror%|/|%"))
syntaxError(tok);
if (Token::Match(tok, "[;([{] %comp%|&&|%oror%|%or%|%|/|^"))
if (Token::Match(tok, "[;([{] %comp%|&&|%oror%|%or%|%|/"))
syntaxError(tok);
if (Token::Match(tok, "%cop%|= ]") && !(isCPP() && Token::Match(tok->previous(), "%type%|[|,|%num% &|=|> ]")))
syntaxError(tok);
Expand Down
8 changes: 4 additions & 4 deletions test/testtoken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,12 +751,12 @@ class TestToken : public TestFixture {
// cppcheck-suppress simplePatternError - this is intentional
ASSERT_EQUALS(false, Token::Match(bitwiseOr.front(), "; %oror%"));

const SimpleTokenizer bitwiseOrAssignment(*this, ";|=;");
const SimpleTokenList bitwiseOrAssignment(";|=;");
// cppcheck-suppress simplePatternError - this is intentional
ASSERT_EQUALS(false, Token::Match(bitwiseOrAssignment.tokens(), "; %or%"));
ASSERT_EQUALS(true, Token::Match(bitwiseOrAssignment.tokens(), "; %op%"));
ASSERT_EQUALS(false, Token::Match(bitwiseOrAssignment.front(), "; %or%"));
ASSERT_EQUALS(true, Token::Match(bitwiseOrAssignment.front(), "; %op%"));
// cppcheck-suppress simplePatternError - this is intentional
ASSERT_EQUALS(false, Token::Match(bitwiseOrAssignment.tokens(), "; %oror%"));
ASSERT_EQUALS(false, Token::Match(bitwiseOrAssignment.front(), "; %oror%"));

const SimpleTokenList logicalOr(";||;");
// cppcheck-suppress simplePatternError - this is intentional
Expand Down
2 changes: 1 addition & 1 deletion test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7532,7 +7532,7 @@ class TestTokenizer : public TestFixture {
void noCrash1() {
ASSERT_NO_THROW(tokenizeAndStringify(
"struct A {\n"
" A( const std::string &name = " " );\n"
" A( const std::string &name = \" \" );\n"
"};\n"
"A::A( const std::string &name ) { return; }\n"));
}
Expand Down

0 comments on commit 064fd52

Please sign in to comment.