Skip to content

Commit

Permalink
Merge branch 'danmar:main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
dsamo authored Apr 5, 2024
2 parents 70a4672 + d19af9b commit 811f535
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8613,9 +8613,11 @@ void Tokenizer::findGarbageCode() const
syntaxError(tok);
if (Token::Match(tok, "%assign% typename|class %assign%"))
syntaxError(tok);
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%"))
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assert({:=;})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
i f(n*a){n b=0;*a=b;%*a=b;--------------------b}
2 changes: 1 addition & 1 deletion test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,7 @@ class TestGarbage : public TestFixture {
}

void garbageCode203() { // #8972
checkCode("{ > () {} }");
ASSERT_THROW(checkCode("{ > () {} }"), InternalError);
checkCode("template <> a > ::b();");
}

Expand Down
10 changes: 5 additions & 5 deletions test/testtoken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,20 +743,20 @@ class TestToken : public TestFixture {
ASSERT_EQUALS(true, Token::Match(negative.front(), "%bool%"));
}

void matchOr() {
void matchOr() const {
const SimpleTokenList bitwiseOr(";|;");
// cppcheck-suppress simplePatternError - this is intentional
ASSERT_EQUALS(true, Token::Match(bitwiseOr.front(), "; %or%"));
ASSERT_EQUALS(true, Token::Match(bitwiseOr.front(), "; %op%"));
// 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 @@ -7539,7 +7539,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 811f535

Please sign in to comment.