diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index c451f9498..bc1c7d5dd 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9439,7 +9439,7 @@ void Tokenizer::findGarbageCode() const if (match1 && match2) syntaxError(tok); } - if (Token::Match(tok, "%comp%|+|-|/|% )|]|}")) { + if (Token::Match(tok, "%or%|%oror%|~|^|!|%comp%|+|-|/|% )|]|}")) { if (isC()) syntaxError(tok, tok->str() + tok->next()->str()); if (tok->str() != ">" && !Token::simpleMatch(tok->previous(), "operator")) diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index c23788654..178732ec2 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -244,6 +244,7 @@ private: TEST_CASE(garbageCode210); // #8762 TEST_CASE(garbageCode211); // #8764 TEST_CASE(garbageCode212); // #8765 + TEST_CASE(garbageCode213); // #8758 TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1 @@ -1661,6 +1662,10 @@ private: ASSERT_THROW(checkCode("{(){}[]typedef r n00e0[](((n00e0 0((;()))))){(0 typedef n00e0 bre00 n00e0())}[]();typedef n n00e0()[],(bre00)}"), InternalError); } + void garbageCode213() { // #8758 + ASSERT_THROW(checkCode("{\"\"[(1||)];}"), InternalError); + } + void syntaxErrorFirstToken() { ASSERT_THROW(checkCode("&operator(){[]};"), InternalError); // #7818 ASSERT_THROW(checkCode("*(*const<> (size_t); foo) { } *(*const (size_t)() ; foo) { }"), InternalError); // #6858