DDC : constant Boolean := Do_Division_Check (N);
Is_Stoele_Mod : constant Boolean :=
- Is_RTE (First_Subtype (Typ), RE_Storage_Offset)
- and then Nkind (Left_Opnd (N)) = N_Unchecked_Type_Conversion
- and then Is_RTE (Etype (Expression (Left_Opnd (N))), RE_Address);
+ Is_RTE (Typ, RE_Address)
+ and then Nkind (Right_Opnd (N)) = N_Unchecked_Type_Conversion
+ and then
+ Is_RTE (Etype (Expression (Right_Opnd (N))), RE_Storage_Offset);
-- True if this is the special mod operator of System.Storage_Elements
Left : Node_Id;
and then ((Llo >= 0 and then Rlo >= 0)
or else
(Lhi <= 0 and then Rhi <= 0))
+ and then not Is_Stoele_Mod
then
Rewrite (N,
Make_Op_Rem (Sloc (N),
Make_Raise_Constraint_Error (Loc,
Condition =>
Make_Op_Le (Loc,
- Left_Opnd => Duplicate_Subexpr_No_Checks (Right),
+ Left_Opnd =>
+ Duplicate_Subexpr_No_Checks (Expression (Right)),
Right_Opnd => Make_Integer_Literal (Loc, 0)),
Reason => CE_Overflow_Check_Failed));
return;
--------------------------------
procedure Resolve_Intrinsic_Operator (N : Node_Id; Typ : Entity_Id) is
- Btyp : constant Entity_Id := Implementation_Base_Type (Typ);
- Op : Entity_Id;
- Arg1 : Node_Id;
- Arg2 : Node_Id;
+ Is_Stoele_Mod : constant Boolean :=
+ Nkind (N) = N_Op_Mod
+ and then Is_RTE (First_Subtype (Typ), RE_Storage_Offset)
+ and then Is_RTE (Etype (Left_Opnd (N)), RE_Address);
+ -- True if this is the special mod operator of System.Storage_Elements,
+ -- which needs to be resolved to the type of the left operand in order
+ -- to implement the correct semantics.
+
+ Btyp : constant Entity_Id :=
+ (if Is_Stoele_Mod
+ then Implementation_Base_Type (Etype (Left_Opnd (N)))
+ else Implementation_Base_Type (Typ));
+ -- The base type to be used for the operator
function Convert_Operand (Opnd : Node_Id) return Node_Id;
-- If the operand is a literal, it cannot be the expression in a
return Res;
end Convert_Operand;
+ -- Local variables
+
+ Arg1 : Node_Id;
+ Arg2 : Node_Id;
+ Op : Entity_Id;
+
-- Start of processing for Resolve_Intrinsic_Operator
begin