Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8610,9 +8610,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 @@ -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