Fixed #9586 (Valuetype: Wrong type for 'true << 1')
This commit is contained in:
parent
8819e19dae
commit
830f901206
|
@ -5182,8 +5182,17 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
|
||||||
const ValueType *vt2 = parent->astOperand2() ? parent->astOperand2()->valueType() : nullptr;
|
const ValueType *vt2 = parent->astOperand2() ? parent->astOperand2()->valueType() : nullptr;
|
||||||
|
|
||||||
if (vt1 && Token::Match(parent, "<<|>>")) {
|
if (vt1 && Token::Match(parent, "<<|>>")) {
|
||||||
if (!mIsCpp || (vt2 && vt2->isIntegral()))
|
if (!mIsCpp || (vt2 && vt2->isIntegral())) {
|
||||||
setValueType(parent, *vt1);
|
if (vt1->type < ValueType::Type::BOOL || vt1->type >= ValueType::Type::INT)
|
||||||
|
setValueType(parent, *vt1);
|
||||||
|
else {
|
||||||
|
ValueType vt(*vt1);
|
||||||
|
vt.type = ValueType::Type::INT; // Integer promotion
|
||||||
|
vt.sign = ValueType::Sign::SIGNED;
|
||||||
|
setValueType(parent, vt);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6564,6 +6564,7 @@ private:
|
||||||
ASSERT_EQUALS("signed int", typeOf("a = 12 >> x;", ">>", "test.c"));
|
ASSERT_EQUALS("signed int", typeOf("a = 12 >> x;", ">>", "test.c"));
|
||||||
ASSERT_EQUALS("", typeOf("a = 12 << x;", "<<", "test.cpp")); // << might be overloaded
|
ASSERT_EQUALS("", typeOf("a = 12 << x;", "<<", "test.cpp")); // << might be overloaded
|
||||||
ASSERT_EQUALS("signed int", typeOf("a = 12 << x;", "<<", "test.c"));
|
ASSERT_EQUALS("signed int", typeOf("a = 12 << x;", "<<", "test.c"));
|
||||||
|
ASSERT_EQUALS("signed int", typeOf("a = true << 1U;", "<<"));
|
||||||
|
|
||||||
// assignment => result has same type as lhs
|
// assignment => result has same type as lhs
|
||||||
ASSERT_EQUALS("unsigned short", typeOf("unsigned short x; x = 3;", "="));
|
ASSERT_EQUALS("unsigned short", typeOf("unsigned short x; x = 3;", "="));
|
||||||
|
|
Loading…
Reference in New Issue