ValueType: better handling of struct member

This commit is contained in:
Daniel Marjamäki 2015-12-30 11:36:46 +01:00
parent c5c386ceb8
commit fdcab8f1bb
2 changed files with 15 additions and 15 deletions

View File

@ -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;
} }

View File

@ -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;", "."));
} }
}; };