1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-29 17:56:21 +00:00

Improved warning messages on UB shifts.

This commit is contained in:
acqn 2020-08-03 01:15:57 +08:00 committed by Oliver Schmidt
parent 2ab7272673
commit ef5a4db12e

View File

@ -139,9 +139,14 @@ void ShiftExpr (struct ExprDesc* Expr)
** the operand, the behaviour is undefined according to the
** standard.
*/
if (Expr2.IVal < 0 || Expr2.IVal >= (long) ExprBits) {
if (Expr2.IVal < 0) {
Warning ("Shift count too large for operand type");
Warning ("Shift count '%ld' is negative", Expr2.IVal);
Expr2.IVal &= ExprBits - 1;
} else if (Expr2.IVal >= (long) ExprBits) {
Warning ("Shift count '%ld' >= width of type", Expr2.IVal);
Expr2.IVal &= ExprBits - 1;
}