Fixed #7245 (ValueType: Wrong result type for 'sint << uint')

This commit is contained in:
Daniel Marjamäki 2015-12-31 20:18:35 +01:00
parent 98756ea7f5
commit e69e952c46
2 changed files with 9 additions and 0 deletions

View File

@ -3675,6 +3675,11 @@ static void setValueType(Token *tok, const ValueType &valuetype)
if (!parent->astOperand1() || !parent->astOperand1()->valueType()) if (!parent->astOperand1() || !parent->astOperand1()->valueType())
return; return;
if (Token::Match(parent, "<<|>>")) {
setValueType(parent,valuetype);
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;

View File

@ -3061,6 +3061,10 @@ private:
ASSERT_EQUALS("long double *", typeOf("long double x; dostuff(&x,1);", "& x ,")); ASSERT_EQUALS("long double *", typeOf("long double x; dostuff(&x,1);", "& x ,"));
ASSERT_EQUALS("int", typeOf("struct X {int i;}; void f(struct X x) { x.i }", ".")); ASSERT_EQUALS("int", typeOf("struct X {int i;}; void f(struct X x) { x.i }", "."));
// shift => result has same type as lhs
ASSERT_EQUALS("int", typeOf("int x; a = x << 1U;", "<<"));
ASSERT_EQUALS("int", typeOf("int x; a = x >> 1U;", ">>"));
// array.. // array..
ASSERT_EQUALS("void * *", typeOf("void * x[10]; a = x + 0;", "+")); ASSERT_EQUALS("void * *", typeOf("void * x[10]; a = x + 0;", "+"));
ASSERT_EQUALS("int *", typeOf("int x[10]; a = x + 1;", "+")); ASSERT_EQUALS("int *", typeOf("int x[10]; a = x + 1;", "+"));