Determine_Range (N, VOK, Vlo, Vhi, Assume_Valid => True);
if VOK and then Tlo <= Vlo and then Vhi <= Thi then
- Rewrite (Left_Opnd (N),
- Make_Type_Conversion (Loc,
- Subtype_Mark => New_Occurrence_Of (Target_Type, Loc),
- Expression => Relocate_Node (Left_Opnd (N))));
-
- Rewrite (Right_Opnd (N),
- Make_Type_Conversion (Loc,
- Subtype_Mark => New_Occurrence_Of (Target_Type, Loc),
- Expression => Relocate_Node (Right_Opnd (N))));
-
-- Rewrite the conversion operand so that the original
-- node is retained, in order to avoid the warning for
-- redundant conversions in Resolve_Type_Conversion.
- Rewrite (N, Relocate_Node (N));
+ declare
+ Op : constant Node_Id := New_Op_Node (Nkind (N), Loc);
+ begin
+ Set_Left_Opnd (Op,
+ Make_Type_Conversion (Loc,
+ Subtype_Mark =>
+ New_Occurrence_Of (Target_Type, Loc),
+ Expression => Relocate_Node (Left_Opnd (N))));
+ Set_Right_Opnd (Op,
+ Make_Type_Conversion (Loc,
+ Subtype_Mark =>
+ New_Occurrence_Of (Target_Type, Loc),
+ Expression => Relocate_Node (Right_Opnd (N))));
+
+ Rewrite (N, Op);
+ end;
Set_Etype (N, Target_Type);
Remove_Side_Effects (Op1, Name_Req => True);
Remove_Side_Effects (Op2, Name_Req => True);
- Rewrite (Op1,
- Make_Function_Call (Sloc (Op1),
- Name => New_Occurrence_Of (RTE (Comp), Loc),
+ declare
+ Comp_Call : constant Node_Id :=
+ Make_Function_Call (Loc,
+ Name => New_Occurrence_Of (RTE (Comp), Loc),
- Parameter_Associations => New_List (
- Make_Attribute_Reference (Loc,
- Prefix => Relocate_Node (Op1),
- Attribute_Name => Name_Address),
+ Parameter_Associations => New_List (
+ Make_Attribute_Reference (Loc,
+ Prefix => Relocate_Node (Op1),
+ Attribute_Name => Name_Address),
- Make_Attribute_Reference (Loc,
- Prefix => Relocate_Node (Op2),
- Attribute_Name => Name_Address),
+ Make_Attribute_Reference (Loc,
+ Prefix => Relocate_Node (Op2),
+ Attribute_Name => Name_Address),
- Make_Attribute_Reference (Loc,
- Prefix => Relocate_Node (Op1),
- Attribute_Name => Name_Length),
+ Make_Attribute_Reference (Loc,
+ Prefix => Relocate_Node (Op1),
+ Attribute_Name => Name_Length),
- Make_Attribute_Reference (Loc,
- Prefix => Relocate_Node (Op2),
- Attribute_Name => Name_Length))));
+ Make_Attribute_Reference (Loc,
+ Prefix => Relocate_Node (Op2),
+ Attribute_Name => Name_Length)));
+
+ Zero : constant Node_Id :=
+ Make_Integer_Literal (Loc,
+ Intval => Uint_0);
- Rewrite (Op2,
- Make_Integer_Literal (Sloc (Op2),
- Intval => Uint_0));
+ Comp_Op : Node_Id;
- Analyze_And_Resolve (Op1, Standard_Integer);
- Analyze_And_Resolve (Op2, Standard_Integer);
+ begin
+ case Nkind (N) is
+ when N_Op_Lt =>
+ Comp_Op := Make_Op_Lt (Loc, Comp_Call, Zero);
+ when N_Op_Le =>
+ Comp_Op := Make_Op_Le (Loc, Comp_Call, Zero);
+ when N_Op_Gt =>
+ Comp_Op := Make_Op_Gt (Loc, Comp_Call, Zero);
+ when N_Op_Ge =>
+ Comp_Op := Make_Op_Ge (Loc, Comp_Call, Zero);
+ when others =>
+ raise Program_Error;
+ end case;
+
+ Rewrite (N, Comp_Op);
+ end;
+
+ Analyze_And_Resolve (N, Standard_Boolean);
return;
end if;
end if;
-- avoids anomalies when the replacement is done in an instance and
-- is epsilon more efficient.
- Set_Entity (N, Standard_Entity (S_Op_Rem));
+ pragma Assert (Entity (N) = Standard_Op_Rem);
Set_Etype (N, Typ);
Set_Do_Division_Check (N, DDC);
Expand_N_Op_Rem (N);
and then not Known_To_Have_Preelab_Init (Etype (E1))
then
- -- For other than access type, go back to original node to
- -- deal with case where original unset reference has been
- -- rewritten during expansion.
-
- -- In some cases, the original node may be a type
- -- conversion, a qualification or an attribute reference and
- -- in this case we want the object entity inside. Same for
- -- an expression with actions.
-
- UR := Original_Node (UR);
- loop
- if Nkind (UR) in N_Expression_With_Actions
- | N_Qualified_Expression
- | N_Type_Conversion
- then
- UR := Expression (UR);
-
- elsif Nkind (UR) = N_Attribute_Reference then
- UR := Prefix (UR);
-
- else
- exit;
- end if;
- end loop;
-
-- Don't issue warning if appearing inside Initial_Condition
-- pragma or aspect, since that expression is not evaluated
-- at the point where it occurs in the source.