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
8583
8583
bool match1 = Token::Match (tok, " %or%|%oror%|==|!=|+|-|/|!|>=|<=|~|^|++|--|::|sizeof" );
8584
8584
bool match2 = Token::Match (tok->next (), " {|if|else|while|do|for|return|switch|break" );
8585
8585
if (isCPP ()) {
8586
- match1 = match1 || Token::Match (tok, " ::| throw|decltype|typeof" );
8586
+ match1 = match1 || Token::Match (tok, " throw|decltype|typeof" );
8587
8587
match2 = match2 || Token::Match (tok->next (), " try|catch|namespace" );
8588
8588
}
8589
+ if (match1 && !tok->isIncDecOp ()) {
8590
+ match2 = match2 || Token::Match (tok->next (), " %assign%" );
8591
+ }
8589
8592
if (match1 && match2)
8590
8593
syntaxError (tok);
8591
8594
}
Original file line number Diff line number Diff line change @@ -253,6 +253,7 @@ class TestGarbage : public TestFixture {
253
253
TEST_CASE (garbageCode222); // #10763
254
254
TEST_CASE (garbageCode223); // #11639
255
255
TEST_CASE (garbageCode224);
256
+ TEST_CASE (garbageCode225);
256
257
257
258
TEST_CASE (garbageCodeFuzzerClientMode1); // test cases created with the fuzzer client, mode 1
258
259
@@ -1746,6 +1747,10 @@ class TestGarbage : public TestFixture {
1746
1747
checkCode (" void f(){ auto* b = dynamic_cast<const }" ); // don't crash
1747
1748
(void )errout_str (); // we are not interested in the output
1748
1749
}
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
+ }
1749
1754
1750
1755
void syntaxErrorFirstToken () {
1751
1756
ASSERT_THROW (checkCode (" &operator(){[]};" ), InternalError); // #7818
Original file line number Diff line number Diff line change @@ -6794,7 +6794,7 @@ class TestUnusedVar : public TestFixture {
6794
6794
" int a = 0;\n "
6795
6795
" do {\n "
6796
6796
" dostuff(a);\n "
6797
- " } while((a + = x) < 30);\n "
6797
+ " } while((a += x) < 30);\n "
6798
6798
" }" );
6799
6799
ASSERT_EQUALS (" " , errout_str ());
6800
6800
You can’t perform that action at this time.
0 commit comments