From 7bafbfbd6eaa5f02dc0f0bf1d3925533fa654a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 4 Jan 2015 13:50:54 +0100 Subject: [PATCH] Tokenizer: cleanup simplification of '!= 0' to avoid FP in 'x[(y & 0x80) != 0]' (linux) --- lib/tokenize.cpp | 4 ---- test/testother.cpp | 2 +- test/testsimplifytokens.cpp | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 573a41539..7fb0ecc43 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6142,10 +6142,6 @@ void Tokenizer::simplifyIfNotNull() } } - else if (tok->link() && Token::simpleMatch(tok, ") != 0")) { - deleteFrom = tok; - } - if (deleteFrom) { Token::eraseTokens(deleteFrom, deleteFrom->tokAt(3)); tok = deleteFrom; diff --git a/test/testother.cpp b/test/testother.cpp index 5eb43ade0..db1febaa8 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -579,7 +579,7 @@ private: ASSERT_EQUALS("[test.cpp:1]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str()); invalidFunctionUsage("int f() { memset(a,b,sizeof(a)!=0); }"); - TODO_ASSERT_EQUALS("error", "", errout.str()); + ASSERT_EQUALS("[test.cpp:1]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str()); invalidFunctionUsage("int f() { strtol(a,b,sizeof(a)!=12); }"); 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()); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index a4f34eb7f..1a68307c8 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1668,7 +1668,7 @@ private: ASSERT_EQUALS("char * s ; do { s = new char [ 10 ] ; } while ( ! s ) ;", tok("char *s; do { } while (0 == (s=new char[10]));")); // #4911 - ASSERT_EQUALS("; do { current = f ( ) ; } while ( current ) ;", simplifyIfAndWhileAssign(";do { } while((current=f()) != NULL);")); + ASSERT_EQUALS("; do { current = f ( ) ; } while ( ( current ) != 0 ) ;", simplifyIfAndWhileAssign(";do { } while((current=f()) != NULL);")); } void ifnot() {