Fixed #7395 (ValueType: Result type of assignment operators)

This commit is contained in:
Daniel Marjamäki 2016-03-21 19:51:09 +01:00
parent 19c0bccfee
commit 4e4873772d
2 changed files with 9 additions and 0 deletions

View File

@ -3688,6 +3688,12 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
return;
}
if (parent->isAssignmentOp()) {
if (vt1)
setValueType(parent, *vt1, cpp, defaultSignedness);
return;
}
if (parent->str() == "[" && valuetype.pointer > 0U) {
ValueType vt(valuetype);
vt.pointer -= 1U;

View File

@ -3220,6 +3220,9 @@ private:
ASSERT_EQUALS("", typeOf("a = 12 << x;", "<<", "test.cpp")); // << might be overloaded
ASSERT_EQUALS("signed int", typeOf("a = 12 << x;", "<<", "test.c"));
// assignment => result has same type as lhs
ASSERT_EQUALS("unsigned short", typeOf("unsigned short x; x = 3;", "="));
// array..
ASSERT_EQUALS("void * *", typeOf("void * x[10]; a = x + 0;", "+"));
ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = x + 1;", "+"));