From f43f4711248e531bd99de638e53bc74fd1a009b2 Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sun, 4 May 2025 16:00:08 +0200 Subject: [PATCH] Fix internal const cast --- oscar64/Declaration.cpp | 2 +- oscar64/NativeCodeGenerator.cpp | 2 +- oscar64/Parser.cpp | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/oscar64/Declaration.cpp b/oscar64/Declaration.cpp index c2a4d26..49d312e 100644 --- a/oscar64/Declaration.cpp +++ b/oscar64/Declaration.cpp @@ -2428,7 +2428,7 @@ Declaration* Declaration::ToMutableType(void) ndec->mBase = mBase; ndec->mBits = mBits; ndec->mShift = mShift; - ndec->mFlags = mFlags | DTF_CONST; + ndec->mFlags = mFlags & ~DTF_CONST; ndec->mScope = mScope; ndec->mParams = mParams; ndec->mIdent = mIdent; diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index 0689ee4..8a65c6a 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -53089,7 +53089,7 @@ bool NativeCodeBasicBlock::PeepHoleOptimizerExits(int pass) mIns[sz - 3] = mIns[sz - 1]; mIns[sz - 1].mType = ASMIT_NOP; mIns[sz - 1].mMode = ASMIM_IMPLIED; - mIns[sz - 2].mLive |= LIVE_CPU_REG_Z; + mIns[sz - 2].mLive |= LIVE_CPU_REG_Z | LIVE_CPU_REG_X; if (mIns[sz - 2].ReferencesYReg()) mIns[sz - 3].mLive |= LIVE_CPU_REG_Y; if (mBranch == ASMIT_BCC) mBranch = ASMIT_BPL; diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 7283d33..89493e5 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -8973,7 +8973,7 @@ Expression* Parser::ParseAddExpression(bool lhs) if (mCompilerOptions & COPT_CPLUSPLUS) mErrors->Error(mScanner->mLocation, ERRR_INVALID_VOID_POINTER_ARITHMETIC, "Invalid arithmetic on void pointer"); else - mErrors->Error(mScanner->mLocation, EWARN_INVALID_VOID_POINTER_ARITHMETIC, "Invalid arithmetic on void pointer"); + mErrors->Error(mScanner->mLocation, EWARN_INVALID_VOID_POINTER_ARITHMETIC, "Invalid arithmetic on void pointer"); } nexp->mDecType = nexp->mLeft->mDecType; } @@ -9010,6 +9010,10 @@ Expression* Parser::ParseAddExpression(bool lhs) } else if (nexp->mLeft->mDecType->mType == DT_TYPE_FLOAT || nexp->mRight->mDecType->mType == DT_TYPE_FLOAT) nexp->mDecType = TheFloatTypeDeclaration; + else if (nexp->mToken == TK_SUB && + (nexp->mLeft->mDecType->mType == DT_TYPE_POINTER || nexp->mLeft->mDecType->mType == DT_TYPE_ARRAY) && + (nexp->mRight->mDecType->mType == DT_TYPE_POINTER || nexp->mRight->mDecType->mType == DT_TYPE_ARRAY)) + nexp->mDecType = TheSignedIntTypeDeclaration; else nexp->mDecType = exp->mDecType; @@ -10710,7 +10714,7 @@ Expression* Parser::ParseStatement(void) if (mFunctionType->mBase->mType == DT_TYPE_AUTO || mFunctionType->mBase->IsReference() && mFunctionType->mBase->mBase->mType == DT_TYPE_AUTO) { mFunctionType->mBase = mFunctionType->mBase->DeduceAuto(exp->mLeft->mDecType); - ; + if (mFunctionType->mBase->mType == DT_TYPE_STRUCT) { // Make room for value struct return