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;
|
||||
|
||||
if (parent->str() == "[" && valuetype.pointer > 0U) {
|
||||
setValueType(parent, ValueType(valuetype.sign,
|
||||
valuetype.type,
|
||||
valuetype.pointer - 1U,
|
||||
valuetype.constness >> 1,
|
||||
valuetype.originalTypeName));
|
||||
ValueType vt(valuetype);
|
||||
vt.pointer -= 1U;
|
||||
vt.constness >>= 1;
|
||||
setValueType(parent, vt);
|
||||
return;
|
||||
}
|
||||
if (parent->str() == "*" && !parent->astOperand2() && valuetype.pointer > 0U) {
|
||||
setValueType(parent, ValueType(valuetype.sign,
|
||||
valuetype.type,
|
||||
valuetype.pointer - 1U,
|
||||
valuetype.constness >> 1,
|
||||
valuetype.originalTypeName));
|
||||
ValueType vt(valuetype);
|
||||
vt.pointer -= 1U;
|
||||
vt.constness >>= 1;
|
||||
setValueType(parent, vt);
|
||||
return;
|
||||
}
|
||||
if (parent->str() == "&" && !parent->astOperand2()) {
|
||||
setValueType(parent, ValueType(valuetype.sign,
|
||||
valuetype.type,
|
||||
valuetype.pointer + 1U,
|
||||
valuetype.constness,
|
||||
valuetype.originalTypeName));
|
||||
ValueType vt(valuetype);
|
||||
vt.pointer += 1U;
|
||||
setValueType(parent, vt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3084,6 +3084,10 @@ private:
|
|||
// function call..
|
||||
ASSERT_EQUALS("int", typeOf("int a(int); a(5);", "( 5"));
|
||||
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