Fix binary and/or with boolean values, now raising a warning
This commit is contained in:
parent
a60f5a783f
commit
5a1ff68926
|
@ -21,6 +21,7 @@ enum ErrorID
|
||||||
EWARN_INDEX_OUT_OF_BOUNDS,
|
EWARN_INDEX_OUT_OF_BOUNDS,
|
||||||
EWARN_SYNTAX,
|
EWARN_SYNTAX,
|
||||||
EWARN_NOT_INTERRUPT_SAFE,
|
EWARN_NOT_INTERRUPT_SAFE,
|
||||||
|
EWARN_BOOL_SHORTCUT,
|
||||||
|
|
||||||
EERR_GENERIC = 3000,
|
EERR_GENERIC = 3000,
|
||||||
EERR_FILE_NOT_FOUND,
|
EERR_FILE_NOT_FOUND,
|
||||||
|
|
|
@ -1542,6 +1542,14 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
|
||||||
dtype = TheUnsignedIntTypeDeclaration;
|
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);
|
vl = CoerceType(proc, block, vl, dtype);
|
||||||
vr = CoerceType(proc, block, vr, dtype);
|
vr = CoerceType(proc, block, vr, dtype);
|
||||||
|
|
||||||
|
|
|
@ -19085,7 +19085,7 @@ void NativeCodeBasicBlock::BuildPlacement(GrowingArray<NativeCodeBasicBlock*>& p
|
||||||
{
|
{
|
||||||
if (!mPlaced)
|
if (!mPlaced)
|
||||||
{
|
{
|
||||||
assert(mBranch != ASMIT_JMP || mIns.Size() > 0);
|
assert(mBranch != ASMIT_JMP || mIns.Size() > 0 || mTrueJump == this);
|
||||||
|
|
||||||
mPlaced = true;
|
mPlaced = true;
|
||||||
mPlace = placement.Size();
|
mPlace = placement.Size();
|
||||||
|
|
Loading…
Reference in New Issue