Skip to content

Commit

Permalink
Fix #12659 False positive: syntaxError when there is && in array argu…
Browse files Browse the repository at this point in the history
…ment (#6341)
  • Loading branch information
chrchr-github authored Apr 25, 2024
1 parent 4efb001 commit e5659cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8653,7 +8653,7 @@ void Tokenizer::findGarbageCode() const
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
3 changes: 3 additions & 0 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7134,6 +7134,9 @@ class TestTokenizer : public TestFixture {
ASSERT_NO_THROW(tokenizeAndStringify("S* g = ::new(ptr) S();")); // #12552
ASSERT_NO_THROW(tokenizeAndStringify("void f(int* p) { return ::delete p; }"));

ASSERT_NO_THROW(tokenizeAndStringify("template <typename T, int N>\n" // #12659
"constexpr void f(T(&&a)[N]) {}"));

ignore_errout();
}

Expand Down

0 comments on commit e5659cc

Please sign in to comment.