From 13f3ea57a3785b669bbbb1ad4c608a4c217d12f1 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sat, 19 Mar 2022 19:46:40 +0100 Subject: [PATCH] Fix signed unsigned shift with mixed signed arguments --- oscar64/InterCodeGenerator.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index 56bdf62..d576073 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -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)