mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 17:30:50 +00:00
Added basic shift count check for <<= and >>= operations.
This commit is contained in:
parent
2c3ca15d90
commit
d0c9b2de99
@ -322,6 +322,12 @@ static void OpAssignBitField (const GenDesc* Gen, ExprDesc* Expr, const char* Op
|
|||||||
} else if (Gen->Func == g_mod) {
|
} else if (Gen->Func == g_mod) {
|
||||||
Error ("Modulo operation with zero");
|
Error ("Modulo operation with zero");
|
||||||
}
|
}
|
||||||
|
} else if (Gen->Func == g_asl || Gen->Func == g_asr) {
|
||||||
|
if (Expr2.IVal < 0) {
|
||||||
|
Warning ("Shift count '%ld' is negative", Expr2.IVal);
|
||||||
|
} else if (Expr2.IVal >= (long)(SizeOf (Expr->Type) * 8)) {
|
||||||
|
Warning ("Shift count '%ld' >= width of type", Expr2.IVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adjust the types of the operands if needed */
|
/* Adjust the types of the operands if needed */
|
||||||
@ -502,6 +508,12 @@ static void OpAssignArithmetic (const GenDesc* Gen, ExprDesc* Expr, const char*
|
|||||||
} else if (Gen->Func == g_mod) {
|
} else if (Gen->Func == g_mod) {
|
||||||
Error ("Modulo operation with zero");
|
Error ("Modulo operation with zero");
|
||||||
}
|
}
|
||||||
|
} else if (Gen->Func == g_asl || Gen->Func == g_asr) {
|
||||||
|
if (Expr2.IVal < 0) {
|
||||||
|
Warning ("Shift count '%ld' is negative", Expr2.IVal);
|
||||||
|
} else if (Expr2.IVal >= (long)(SizeOf (Expr->Type) * 8)) {
|
||||||
|
Warning ("Shift count '%ld' >= width of type", Expr2.IVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Gen->Func (Flags | CF_CONST, Expr2.IVal);
|
Gen->Func (Flags | CF_CONST, Expr2.IVal);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user