ValueType: Support ++/--.
This commit is contained in:
parent
2b179dc836
commit
792835cd9a
|
@ -3738,7 +3738,7 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
|
||||||
if (ternary)
|
if (ternary)
|
||||||
parent = const_cast<Token*>(parent->astParent());
|
parent = const_cast<Token*>(parent->astParent());
|
||||||
|
|
||||||
if (ternary || parent->isArithmeticalOp()) {
|
if (ternary || parent->isArithmeticalOp() || parent->tokType() == Token::eIncDecOp) {
|
||||||
if (vt1->pointer != 0U && vt2 && vt2->pointer == 0U) {
|
if (vt1->pointer != 0U && vt2 && vt2->pointer == 0U) {
|
||||||
setValueType(parent, *vt1, cpp, defaultSignedness);
|
setValueType(parent, *vt1, cpp, defaultSignedness);
|
||||||
return;
|
return;
|
||||||
|
@ -3750,7 +3750,7 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vt1->pointer != 0U) {
|
if (vt1->pointer != 0U) {
|
||||||
if (ternary) // result is pointer
|
if (ternary || parent->tokType() == Token::eIncDecOp) // result is pointer
|
||||||
setValueType(parent, *vt1, cpp, defaultSignedness);
|
setValueType(parent, *vt1, cpp, defaultSignedness);
|
||||||
else // result is pointer diff
|
else // result is pointer diff
|
||||||
setValueType(parent, ValueType(ValueType::Sign::UNSIGNED, ValueType::Type::INT, 0U, 0U, "ptrdiff_t"), cpp, defaultSignedness);
|
setValueType(parent, ValueType(ValueType::Sign::UNSIGNED, ValueType::Type::INT, 0U, 0U, "ptrdiff_t"), cpp, defaultSignedness);
|
||||||
|
@ -3773,7 +3773,7 @@ static void setValueType(Token *tok, const ValueType &valuetype, bool cpp, Value
|
||||||
|
|
||||||
if (vt1->isIntegral() && vt1->pointer == 0U &&
|
if (vt1->isIntegral() && vt1->pointer == 0U &&
|
||||||
(!vt2 || (vt2->isIntegral() && vt2->pointer == 0U)) &&
|
(!vt2 || (vt2->isIntegral() && vt2->pointer == 0U)) &&
|
||||||
(ternary || parent->isArithmeticalOp() || parent->tokType() == Token::eBitOp || parent->isAssignmentOp())) {
|
(ternary || parent->isArithmeticalOp() || parent->tokType() == Token::eBitOp || parent->tokType() == Token::eIncDecOp || parent->isAssignmentOp())) {
|
||||||
|
|
||||||
ValueType vt;
|
ValueType vt;
|
||||||
if (!vt2 || vt1->type > vt2->type) {
|
if (!vt2 || vt1->type > vt2->type) {
|
||||||
|
|
|
@ -3189,6 +3189,8 @@ 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("long double *", typeOf("long double x; dostuff(&x,1);", "& x ,"));
|
ASSERT_EQUALS("long double *", typeOf("long double x; dostuff(&x,1);", "& x ,"));
|
||||||
ASSERT_EQUALS("signed int", typeOf("struct X {int i;}; void f(struct X x) { x.i }", "."));
|
ASSERT_EQUALS("signed int", typeOf("struct X {int i;}; void f(struct X x) { x.i }", "."));
|
||||||
|
ASSERT_EQUALS("signed int *", typeOf("int *p; a = p++;", "++"));
|
||||||
|
ASSERT_EQUALS("signed int", typeOf("int x; a = x++;", "++"));
|
||||||
|
|
||||||
// Unary arithmetic/bit operators
|
// Unary arithmetic/bit operators
|
||||||
ASSERT_EQUALS("signed int", typeOf("int x; a = -x;", "-"));
|
ASSERT_EQUALS("signed int", typeOf("int x; a = -x;", "-"));
|
||||||
|
|
Loading…
Reference in New Issue