ValueType: better handling of struct member
This commit is contained in:
parent
c5c386ceb8
commit
fdcab8f1bb
|
@ -3676,27 +3676,23 @@ static void setValueType(Token *tok, const ValueType &valuetype)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (parent->str() == "[" && valuetype.pointer > 0U) {
|
if (parent->str() == "[" && valuetype.pointer > 0U) {
|
||||||
setValueType(parent, ValueType(valuetype.sign,
|
ValueType vt(valuetype);
|
||||||
valuetype.type,
|
vt.pointer -= 1U;
|
||||||
valuetype.pointer - 1U,
|
vt.constness >>= 1;
|
||||||
valuetype.constness >> 1,
|
setValueType(parent, vt);
|
||||||
valuetype.originalTypeName));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parent->str() == "*" && !parent->astOperand2() && valuetype.pointer > 0U) {
|
if (parent->str() == "*" && !parent->astOperand2() && valuetype.pointer > 0U) {
|
||||||
setValueType(parent, ValueType(valuetype.sign,
|
ValueType vt(valuetype);
|
||||||
valuetype.type,
|
vt.pointer -= 1U;
|
||||||
valuetype.pointer - 1U,
|
vt.constness >>= 1;
|
||||||
valuetype.constness >> 1,
|
setValueType(parent, vt);
|
||||||
valuetype.originalTypeName));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (parent->str() == "&" && !parent->astOperand2()) {
|
if (parent->str() == "&" && !parent->astOperand2()) {
|
||||||
setValueType(parent, ValueType(valuetype.sign,
|
ValueType vt(valuetype);
|
||||||
valuetype.type,
|
vt.pointer += 1U;
|
||||||
valuetype.pointer + 1U,
|
setValueType(parent, vt);
|
||||||
valuetype.constness,
|
|
||||||
valuetype.originalTypeName));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3084,6 +3084,10 @@ private:
|
||||||
// function call..
|
// function call..
|
||||||
ASSERT_EQUALS("int", typeOf("int a(int); a(5);", "( 5"));
|
ASSERT_EQUALS("int", typeOf("int a(int); a(5);", "( 5"));
|
||||||
ASSERT_EQUALS("unsigned long", typeOf("sizeof(x);", "("));
|
ASSERT_EQUALS("unsigned long", typeOf("sizeof(x);", "("));
|
||||||
|
|
||||||
|
// struct member..
|
||||||
|
ASSERT_EQUALS("int", typeOf("struct AB { int a; int b; } ab; x = ab.a;", "."));
|
||||||
|
ASSERT_EQUALS("int", typeOf("struct AB { int a; int b; } *ab; x = ab[1].a;", "."));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue