Revert "Fixed #7888 (1.77 false positive from knownConditionTrueFalse with sizeof(int) == sizeof(long))"

This reverts commit a762511067.
This commit is contained in:
Daniel Marjamäki 2017-01-10 13:22:48 +01:00
parent 7bdd001a5f
commit 47d39d0a14
2 changed files with 8 additions and 1 deletions

View File

@ -728,27 +728,35 @@ static Token * valueFlowSetConstantValue(const Token *tok, const Settings *setti
const ValueType &vt = ValueType::parseDecl(tok2,settings); const ValueType &vt = ValueType::parseDecl(tok2,settings);
if (vt.pointer) { if (vt.pointer) {
ValueFlow::Value value(settings->sizeof_pointer); ValueFlow::Value value(settings->sizeof_pointer);
value.setKnown();
setTokenValue(const_cast<Token *>(tok->next()), value, settings); setTokenValue(const_cast<Token *>(tok->next()), value, settings);
} else if (vt.type == ValueType::Type::CHAR) { } else if (vt.type == ValueType::Type::CHAR) {
ValueFlow::Value value(1); ValueFlow::Value value(1);
value.setKnown();
setTokenValue(const_cast<Token *>(tok->next()), value, settings); setTokenValue(const_cast<Token *>(tok->next()), value, settings);
} else if (vt.type == ValueType::Type::SHORT) { } else if (vt.type == ValueType::Type::SHORT) {
ValueFlow::Value value(settings->sizeof_short); ValueFlow::Value value(settings->sizeof_short);
value.setKnown();
setTokenValue(const_cast<Token *>(tok->next()), value, settings); setTokenValue(const_cast<Token *>(tok->next()), value, settings);
} else if (vt.type == ValueType::Type::INT) { } else if (vt.type == ValueType::Type::INT) {
ValueFlow::Value value(settings->sizeof_int); ValueFlow::Value value(settings->sizeof_int);
value.setKnown();
setTokenValue(const_cast<Token *>(tok->next()), value, settings); setTokenValue(const_cast<Token *>(tok->next()), value, settings);
} else if (vt.type == ValueType::Type::LONG) { } else if (vt.type == ValueType::Type::LONG) {
ValueFlow::Value value(settings->sizeof_long); ValueFlow::Value value(settings->sizeof_long);
value.setKnown();
setTokenValue(const_cast<Token *>(tok->next()), value, settings); setTokenValue(const_cast<Token *>(tok->next()), value, settings);
} else if (vt.type == ValueType::Type::LONGLONG) { } else if (vt.type == ValueType::Type::LONGLONG) {
ValueFlow::Value value(settings->sizeof_long_long); ValueFlow::Value value(settings->sizeof_long_long);
value.setKnown();
setTokenValue(const_cast<Token *>(tok->next()), value, settings); setTokenValue(const_cast<Token *>(tok->next()), value, settings);
} else if (vt.type == ValueType::Type::FLOAT) { } else if (vt.type == ValueType::Type::FLOAT) {
ValueFlow::Value value(settings->sizeof_float); ValueFlow::Value value(settings->sizeof_float);
value.setKnown();
setTokenValue(const_cast<Token *>(tok->next()), value, settings); setTokenValue(const_cast<Token *>(tok->next()), value, settings);
} else if (vt.type == ValueType::Type::DOUBLE) { } else if (vt.type == ValueType::Type::DOUBLE) {
ValueFlow::Value value(settings->sizeof_double); ValueFlow::Value value(settings->sizeof_double);
value.setKnown();
setTokenValue(const_cast<Token *>(tok->next()), value, settings); setTokenValue(const_cast<Token *>(tok->next()), value, settings);
} }
} }

View File

@ -493,7 +493,6 @@ private:
values = tokenValues(code,"( int )"); values = tokenValues(code,"( int )");
ASSERT_EQUALS(1U, values.size()); ASSERT_EQUALS(1U, values.size());
ASSERT_EQUALS(settings.sizeof_int, values.back().intvalue); ASSERT_EQUALS(settings.sizeof_int, values.back().intvalue);
ASSERT_EQUALS(false, values.back().isKnown()); // value is different on different platforms (#7888)
code = "void f() {\n" code = "void f() {\n"
" struct S *a[10];" " struct S *a[10];"