diff --git a/oscar64/Errors.h b/oscar64/Errors.h index 8d0dcbc..2e0cd7b 100644 --- a/oscar64/Errors.h +++ b/oscar64/Errors.h @@ -21,6 +21,7 @@ enum ErrorID EWARN_INDEX_OUT_OF_BOUNDS, EWARN_SYNTAX, EWARN_NOT_INTERRUPT_SAFE, + EWARN_BOOL_SHORTCUT, EERR_GENERIC = 3000, EERR_FILE_NOT_FOUND, diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index be0a728..d143a08 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -1542,6 +1542,14 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration* dtype = TheUnsignedIntTypeDeclaration; } + // Convert bool to char on binary operation + if (dtype->mType == DT_TYPE_BOOL) + { + if (exp->mToken == TK_BINARY_AND || exp->mToken == TK_BINARY_OR) + mErrors->Error(exp->mLocation, EWARN_BOOL_SHORTCUT, "Binary and/or operator used for boolean values, use logical operator ('&&' '||')."); + dtype = TheUnsignedCharTypeDeclaration; + } + vl = CoerceType(proc, block, vl, dtype); vr = CoerceType(proc, block, vr, dtype); diff --git a/oscar64/NativeCodeGenerator.cpp b/oscar64/NativeCodeGenerator.cpp index b69cdef..e391b46 100644 --- a/oscar64/NativeCodeGenerator.cpp +++ b/oscar64/NativeCodeGenerator.cpp @@ -19085,7 +19085,7 @@ void NativeCodeBasicBlock::BuildPlacement(GrowingArray& p { if (!mPlaced) { - assert(mBranch != ASMIT_JMP || mIns.Size() > 0); + assert(mBranch != ASMIT_JMP || mIns.Size() > 0 || mTrueJump == this); mPlaced = true; mPlace = placement.Size();