Skip to content

Commit

Permalink
Fix #12615 FP syntaxError with operator= (danmar#6295)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Apr 15, 2024
1 parent 7e60624 commit 65f571f
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -8636,7 +8636,7 @@ 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% ;")))
if (Token::Match(tok, "%assign% [;)}]") && (!isCPP() || !Token::simpleMatch(tok->previous(), "operator")))
syntaxError(tok);
if (Token::Match(tok, "%cop%|=|,|[ %or%|%oror%|/|%"))
syntaxError(tok);
Expand Down
4 changes: 4 additions & 0 deletions test/testgarbage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class TestGarbage : public TestFixture {
TEST_CASE(garbageCode224);
TEST_CASE(garbageCode225);
TEST_CASE(garbageCode226);
TEST_CASE(garbageCode227);

TEST_CASE(garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1

Expand Down Expand Up @@ -1753,6 +1754,9 @@ class TestGarbage : public TestFixture {
ASSERT_THROW_INTERNAL(checkCode("int a() { (b((c)\\)) } {}"), SYNTAX);
ASSERT_THROW_INTERNAL(checkCode("int a() { (b((c)@)) } {}"), SYNTAX);
}
void garbageCode227() { // #12615
ASSERT_NO_THROW(checkCode("f(&S::operator=);"));
}

void syntaxErrorFirstToken() {
ASSERT_THROW_INTERNAL(checkCode("&operator(){[]};"), SYNTAX); // #7818
Expand Down

0 comments on commit 65f571f

Please sign in to comment.