fix: datatype mismatch in optimized bitshift const value

This commit is contained in:
Irmen de Jong 2020-03-23 22:35:23 +01:00
parent 7426587c38
commit 2c7424fd43

View File

@ -510,12 +510,12 @@ internal class ExpressionSimplifier(private val program: Program) : AstWalker()
when (targetDt) { when (targetDt) {
DataType.UBYTE, DataType.BYTE -> { DataType.UBYTE, DataType.BYTE -> {
if (amount >= 8) { if (amount >= 8) {
return NumericLiteralValue.optimalInteger(0, expr.position) return NumericLiteralValue(targetDt, 0, expr.position)
} }
} }
DataType.UWORD, DataType.WORD -> { DataType.UWORD, DataType.WORD -> {
if (amount >= 16) { if (amount >= 16) {
return NumericLiteralValue.optimalInteger(0, expr.position) return NumericLiteralValue(targetDt, 0, expr.position)
} else if (amount >= 8) { } else if (amount >= 8) {
val lsb = TypecastExpression(expr.left, DataType.UBYTE, true, expr.position) val lsb = TypecastExpression(expr.left, DataType.UBYTE, true, expr.position)
if (amount == 8) { if (amount == 8) {