Fixed #7395 (ValueType: Result type of assignment operators)
This commit is contained in:
parent
19c0bccfee
commit
4e4873772d
|
@ -3688,6 +3688,12 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parent->isAssignmentOp()) {
|
||||||
|
if (vt1)
|
||||||
|
setValueType(parent, *vt1, cpp, defaultSignedness);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (parent->str() == "[" && valuetype.pointer > 0U) {
|
if (parent->str() == "[" && valuetype.pointer > 0U) {
|
||||||
ValueType vt(valuetype);
|
ValueType vt(valuetype);
|
||||||
vt.pointer -= 1U;
|
vt.pointer -= 1U;
|
||||||
|
|
|
@ -3220,6 +3220,9 @@ private:
|
||||||
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"));
|
||||||
|
|
||||||
|
// assignment => result has same type as lhs
|
||||||
|
ASSERT_EQUALS("unsigned short", typeOf("unsigned short x; x = 3;", "="));
|
||||||
|
|
||||||
// array..
|
// array..
|
||||||
ASSERT_EQUALS("void * *", typeOf("void * x[10]; a = x + 0;", "+"));
|
ASSERT_EQUALS("void * *", typeOf("void * x[10]; a = x + 0;", "+"));
|
||||||
ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = x + 1;", "+"));
|
ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = x + 1;", "+"));
|
||||||
|
|
Loading…
Reference in New Issue