Fixed #7888 (1.77 false positive from knownConditionTrueFalse with sizeof(int) == sizeof(long))
This commit is contained in:
parent
b1f7e46491
commit
a762511067
|
@ -728,35 +728,27 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,6 +493,7 @@ 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];"
|
||||||
|
|
Loading…
Reference in New Issue