Commit dfd2da00 by Ed Schonberg Committed by Pierre-Marie de Rodat

[Ada] Convert operands of generated code to Standard.Unsigned for modular ops.

2018-05-31  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* exp_ch4.adb (Expand_Modular_Addition, Expand_Modular_Subtraction):
	Convert all operands of the generated code to Standard.Unsigned, to
	prevent spurious visibility errors. This is needed when the generated
	expansion involves a modular index type of an array type, and the index
	type is not immediately visible.

From-SVN: r260993
parent 5b87c1fe
2018-05-31 Ed Schonberg <schonberg@adacore.com>
* exp_ch4.adb (Expand_Modular_Addition, Expand_Modular_Subtraction):
Convert all operands of the generated code to Standard.Unsigned, to
prevent spurious visibility errors. This is needed when the generated
expansion involves a modular index type of an array type, and the index
type is not immediately visible.
2018-05-30 Piotr Trojanek <trojanek@adacore.com> 2018-05-30 Piotr Trojanek <trojanek@adacore.com>
* einfo.ads (Package_Instantiation): Update comment after a routine * einfo.ads (Package_Instantiation): Update comment after a routine
......
...@@ -4057,8 +4057,12 @@ package body Exp_Ch4 is ...@@ -4057,8 +4057,12 @@ package body Exp_Ch4 is
Else_Expr : constant Node_Id := New_Op_Node (N_Op_Subtract, Else_Expr : constant Node_Id := New_Op_Node (N_Op_Subtract,
Loc); Loc);
begin begin
-- To prevent spurious visibility issues, convert all
-- operands to Standard.Unsigned.
Set_Left_Opnd (Cond_Expr, Set_Left_Opnd (Cond_Expr,
New_Copy_Tree (Left_Opnd (N))); Unchecked_Convert_To (Standard_Unsigned,
New_Copy_Tree (Left_Opnd (N))));
Set_Right_Opnd (Cond_Expr, Set_Right_Opnd (Cond_Expr,
Make_Integer_Literal (Loc, Mod_Minus_Right)); Make_Integer_Literal (Loc, Mod_Minus_Right));
Append_To (Exprs, Cond_Expr); Append_To (Exprs, Cond_Expr);
...@@ -4180,7 +4184,8 @@ package body Exp_Ch4 is ...@@ -4180,7 +4184,8 @@ package body Exp_Ch4 is
Loc); Loc);
begin begin
Set_Left_Opnd (Cond_Expr, Set_Left_Opnd (Cond_Expr,
New_Copy_Tree (Left_Opnd (N))); Unchecked_Convert_To (Standard_Unsigned,
New_Copy_Tree (Left_Opnd (N))));
Set_Right_Opnd (Cond_Expr, Set_Right_Opnd (Cond_Expr,
Make_Integer_Literal (Loc, Intval (Right_Opnd (N)))); Make_Integer_Literal (Loc, Intval (Right_Opnd (N))));
Append_To (Exprs, Cond_Expr); Append_To (Exprs, Cond_Expr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment