Skip to content

Commit 3c2a660

Browse files
authored
Fix cppcheck-opensource#657: combineOperators(): &= gets split up incorrectly (cppcheck-opensource#658)
1 parent 2ce31ac commit 3c2a660

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

simplecpp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ void simplecpp::TokenList::combineOperators()
10401040
continue;
10411041
}
10421042
const Token *prev = tok->previous;
1043-
while (prev && prev->isOneOf(";{}()"))
1043+
while (prev && prev->isOneOf(";{}("))
10441044
prev = prev->previous;
10451045
executableScope.push(prev && prev->op == ')');
10461046
continue;

test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ static void combineOperators_andequal()
493493
ASSERT_EQUALS("x &= 2 ;", preprocess("x &= 2;"));
494494
ASSERT_EQUALS("void f ( x & = 2 ) ;", preprocess("void f(x &= 2);"));
495495
ASSERT_EQUALS("f ( x &= 2 ) ;", preprocess("f(x &= 2);"));
496+
ASSERT_EQUALS("f ( ) { return new int ( i &= 1 ) ; }", preprocess("f () { return new int(i &= 1); }"));
496497
}
497498

498499
static void combineOperators_ellipsis()

0 commit comments

Comments
 (0)