File tree Expand file tree Collapse file tree 3 files changed +10
-2
lines changed
Expand file tree Collapse file tree 3 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -8583,9 +8583,12 @@ void Tokenizer::findGarbageCode() const
85838583 bool match1 = Token::Match (tok, " %or%|%oror%|==|!=|+|-|/|!|>=|<=|~|^|++|--|::|sizeof" );
85848584 bool match2 = Token::Match (tok->next (), " {|if|else|while|do|for|return|switch|break" );
85858585 if (isCPP ()) {
8586- match1 = match1 || Token::Match (tok, " ::| throw|decltype|typeof" );
8586+ match1 = match1 || Token::Match (tok, " throw|decltype|typeof" );
85878587 match2 = match2 || Token::Match (tok->next (), " try|catch|namespace" );
85888588 }
8589+ if (match1 && !tok->isIncDecOp ()) {
8590+ match2 = match2 || Token::Match (tok->next (), " %assign%" );
8591+ }
85898592 if (match1 && match2)
85908593 syntaxError (tok);
85918594 }
Original file line number Diff line number Diff line change @@ -253,6 +253,7 @@ class TestGarbage : public TestFixture {
253253 TEST_CASE (garbageCode222); // #10763
254254 TEST_CASE (garbageCode223); // #11639
255255 TEST_CASE (garbageCode224);
256+ TEST_CASE (garbageCode225);
256257
257258 TEST_CASE (garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
258259
@@ -1746,6 +1747,10 @@ class TestGarbage : public TestFixture {
17461747 checkCode (" void f(){ auto* b = dynamic_cast<const }" ); // don't crash
17471748 (void )errout_str (); // we are not interested in the output
17481749 }
1750+ void garbageCode225 () {
1751+ ASSERT_THROW (checkCode (" int n() { c * s0, 0 s0 = c(sizeof = ) }" ), InternalError);
1752+ ASSERT_THROW (checkCode (" int n() { c * s0, 0 s0 = c(sizeof |= ) }" ), InternalError);
1753+ }
17491754
17501755 void syntaxErrorFirstToken () {
17511756 ASSERT_THROW (checkCode (" &operator(){[]};" ), InternalError); // #7818
Original file line number Diff line number Diff line change @@ -6794,7 +6794,7 @@ class TestUnusedVar : public TestFixture {
67946794 " int a = 0;\n "
67956795 " do {\n "
67966796 " dostuff(a);\n "
6797- " } while((a + = x) < 30);\n "
6797+ " } while((a += x) < 30);\n "
67986798 " }" );
67996799 ASSERT_EQUALS (" " , errout_str ());
68006800
You can’t perform that action at this time.
0 commit comments