-- and T is B for the cases of Body_Version, or Version applied to a
-- subprogram acting as its own spec, and S for Version applied to a
-- subprogram spec or package. This sequence of code references the
- -- the unsigned constant created in the main program by the binder.
+ -- unsigned constant created in the main program by the binder.
-- A special exception occurs for Standard, where the string returned
-- is a copy of the library string in gnatvsn.ads.
Make_Pragma (Loc,
Chars => Name_Import,
Pragma_Argument_Associations => New_List (
- Make_Pragma_Argument_Association (Loc,
- Expression => Lang),
+ Make_Pragma_Argument_Association (Loc, Expression => Lang),
Make_Pragma_Argument_Association (Loc,
- Expression =>
- Make_Identifier (Loc, Chars (Ent))),
+ Expression => Make_Identifier (Loc, Chars (Ent))),
Make_Pragma_Argument_Association (Loc,
- Expression =>
- Make_String_Literal (Loc, Str))))));
+ Expression => Make_String_Literal (Loc, Str))))));
Set_Entity (N, Ent);
Rewrite (N, New_Occurrence_Of (Ent, Loc));
Object_Parm :=
Make_Attribute_Reference (Loc,
- Prefix =>
- Make_Selected_Component (Loc,
- Prefix =>
- Unchecked_Convert_To (New_Itype,
- New_Reference_To
- (First_Entity
- (Protected_Body_Subprogram (Subprg)),
- Loc)),
- Selector_Name =>
- Make_Identifier (Loc, Name_uObject)),
+ Prefix =>
+ Make_Selected_Component (Loc,
+ Prefix =>
+ Unchecked_Convert_To (New_Itype,
+ New_Reference_To
+ (First_Entity
+ (Protected_Body_Subprogram (Subprg)),
+ Loc)),
+ Selector_Name =>
+ Make_Identifier (Loc, Name_uObject)),
Attribute_Name => Name_Unchecked_Access);
end;
(First_Entity
(Protected_Body_Subprogram (Subprg)),
Loc),
- Selector_Name =>
- Make_Identifier (Loc, Name_uObject)),
+ Selector_Name => Make_Identifier (Loc, Name_uObject)),
Attribute_Name => Name_Unchecked_Access);
end if;
-- These checks are not generated for modular types, since the proper
-- semantics for Succ and Pred on modular types is to wrap, not raise CE.
+ -- We also suppress these checks if we are the right side of an assignment
+ -- statement or the expression of an object declaration, where the flag
+ -- Suppress_Assignment_Checks is set for the assignment/declaration.
procedure Expand_Pred_Succ (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
+ P : constant Node_Id := Parent (N);
Cnam : Name_Id;
begin
Cnam := Name_Last;
end if;
- Insert_Action (N,
- Make_Raise_Constraint_Error (Loc,
- Condition =>
- Make_Op_Eq (Loc,
- Left_Opnd =>
- Duplicate_Subexpr_Move_Checks (First (Expressions (N))),
- Right_Opnd =>
- Make_Attribute_Reference (Loc,
- Prefix =>
- New_Reference_To (Base_Type (Etype (Prefix (N))), Loc),
- Attribute_Name => Cnam)),
- Reason => CE_Overflow_Check_Failed));
+ if not Nkind_In (P, N_Assignment_Statement, N_Object_Declaration)
+ or else not Suppress_Assignment_Checks (P)
+ then
+ Insert_Action (N,
+ Make_Raise_Constraint_Error (Loc,
+ Condition =>
+ Make_Op_Eq (Loc,
+ Left_Opnd =>
+ Duplicate_Subexpr_Move_Checks (First (Expressions (N))),
+ Right_Opnd =>
+ Make_Attribute_Reference (Loc,
+ Prefix =>
+ New_Reference_To (Base_Type (Etype (Prefix (N))), Loc),
+ Attribute_Name => Cnam)),
+ Reason => CE_Overflow_Check_Failed));
+ end if;
end Expand_Pred_Succ;
-------------------