-- Determine range to see if it can be larger than MaxS
- Determine_Range
- (Right_Opnd (N), OK, Lo, Hi, Assume_Valid => True);
+ Determine_Range (Exp, OK, Lo, Hi, Assume_Valid => True);
TestS := (not OK) or else Hi > MaxS;
-- Signed integer case
Make_Raise_Constraint_Error (Loc,
Condition =>
Make_Op_Gt (Loc,
- Left_Opnd => Duplicate_Subexpr (Right_Opnd (N)),
+ Left_Opnd => Duplicate_Subexpr (Exp),
Right_Opnd => Make_Integer_Literal (Loc, MaxS)),
Reason => CE_Overflow_Check_Failed));
end if;
Rewrite (N,
Make_Op_Shift_Left (Loc,
Left_Opnd => Make_Integer_Literal (Loc, Uint_1),
- Right_Opnd => Right_Opnd (N)));
+ Right_Opnd => Exp));
-- Modular integer case
Test_Gt :=
Make_Op_Gt (Loc,
- Left_Opnd => Duplicate_Subexpr (Right_Opnd (N)),
+ Left_Opnd => Duplicate_Subexpr (Exp),
Right_Opnd => Make_Integer_Literal (Loc, MaxS));
Rewrite (N,
Make_Integer_Literal (Loc, Uint_0),
Make_Op_Shift_Left (Loc,
Left_Opnd => Make_Integer_Literal (Loc, Uint_1),
- Right_Opnd => Right_Opnd (N)))));
+ Right_Opnd => Exp))));
-- If we know shift count cannot be greater than MaxS, then
-- it is safe to just rewrite as a shift with no test.
Rewrite (N,
Make_Op_Shift_Left (Loc,
Left_Opnd => Make_Integer_Literal (Loc, Uint_1),
- Right_Opnd => Right_Opnd (N)));
+ Right_Opnd => Exp));
end if;
end if;