Skip to content
Open
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: 2 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9018,8 +9018,8 @@ void Tokenizer::findGarbageCode() const
syntaxError(tok);
if (Token::Match(tok, "? %assign%"))
syntaxError(tok);
if (Token::Match(tok, "!|~ %comp%") &&
!(cpp && tok->strAt(1) == ">" && Token::simpleMatch(tok->tokAt(-1), "operator")))
if (Token::Match(tok, "[!~+-/] %comp%") &&
!(cpp && Token::Match(tok->next(), "[<>]") && Token::simpleMatch(tok->tokAt(-1), "operator")))
syntaxError(tok);
if (Token::Match(tok, "%comp% {") && (!cpp || tok->str() != ">"))
syntaxError(tok);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
o o(){i n;for(i x:v)n=n+<1;}
2 changes: 1 addition & 1 deletion test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ class TestGarbage : public TestFixture {
}

void garbageCode95() { // #6804
ASSERT_THROW_INTERNAL(checkCode("{ } x x ; { } h h [ ] ( ) ( ) { struct x ( x ) ; int __attribute__ ( ) f ( ) { h - > first = & x ; struct x * n = h - > first ; ( ) n > } }"), AST); // do not crash
ASSERT_THROW_INTERNAL(checkCode("{ } x x ; { } h h [ ] ( ) ( ) { struct x ( x ) ; int __attribute__ ( ) f ( ) { h - > first = & x ; struct x * n = h - > first ; ( ) n > } }"), SYNTAX); // do not crash
}

void garbageCode96() { // #6807
Expand Down
Loading