Skip to content

Commit 7bafbfb

Browse files
committed
Tokenizer: cleanup simplification of '!= 0' to avoid FP in 'x[(y & 0x80) != 0]' (linux)
1 parent e06a4cd commit 7bafbfb

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

lib/tokenize.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6142,10 +6142,6 @@ void Tokenizer::simplifyIfNotNull()
61426142
}
61436143
}
61446144

6145-
else if (tok->link() && Token::simpleMatch(tok, ") != 0")) {
6146-
deleteFrom = tok;
6147-
}
6148-
61496145
if (deleteFrom) {
61506146
Token::eraseTokens(deleteFrom, deleteFrom->tokAt(3));
61516147
tok = deleteFrom;

test/testother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ class TestOther : public TestFixture {
579579
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str());
580580

581581
invalidFunctionUsage("int f() { memset(a,b,sizeof(a)!=0); }");
582-
TODO_ASSERT_EQUALS("error", "", errout.str());
582+
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str());
583583

584584
invalidFunctionUsage("int f() { strtol(a,b,sizeof(a)!=12); }");
585585
ASSERT_EQUALS("[test.cpp:1]: (error) Invalid strtol() argument nr 3. The value is 0 or 1 (comparison result) but the valid values are '0,2:36'.\n", errout.str());

test/testsimplifytokens.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ class TestSimplifyTokens : public TestFixture {
16681668
ASSERT_EQUALS("char * s ; do { s = new char [ 10 ] ; } while ( ! s ) ;",
16691669
tok("char *s; do { } while (0 == (s=new char[10]));"));
16701670
// #4911
1671-
ASSERT_EQUALS("; do { current = f ( ) ; } while ( current ) ;", simplifyIfAndWhileAssign(";do { } while((current=f()) != NULL);"));
1671+
ASSERT_EQUALS("; do { current = f ( ) ; } while ( ( current ) != 0 ) ;", simplifyIfAndWhileAssign(";do { } while((current=f()) != NULL);"));
16721672
}
16731673

16741674
void ifnot() {

0 commit comments

Comments
 (0)