Fix signed unsigned shift with mixed signed arguments

This commit is contained in:
drmortalwombat 2022-03-19 19:46:40 +01:00
parent 91cb2fda15
commit 13f3ea57a3

View File

@ -1464,6 +1464,23 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
else
dtype = vr.mType;
}
else if (exp->mToken == TK_LEFT_SHIFT || exp->mToken == TK_RIGHT_SHIFT)
{
if (vl.mType->mFlags & DTF_SIGNED)
{
if (vl.mType->mSize == 4)
dtype = TheSignedLongTypeDeclaration;
else
dtype = TheSignedIntTypeDeclaration;
}
else
{
if (vl.mType->mSize == 4 || vr.mType->mSize == 4)
dtype = TheUnsignedLongTypeDeclaration;
else
dtype = TheUnsignedIntTypeDeclaration;
}
}
else if (vr.mType->mSize < vl.mType->mSize && (vl.mType->mFlags & DTF_SIGNED))
{
if (vl.mType->mSize == 4)