From 8cbb664efd48c0be633d1a63a87888da5b77f06d Mon Sep 17 00:00:00 2001 From: Matthew Gingell Date: Thu, 28 Mar 2002 15:33:09 +0000 Subject: * checks.ads: (Remove_Checks): New procedure * checks.adb: (Remove_Checks): New procedure * exp_util.adb: Use new Duplicate_Subexpr functions (Duplicate_Subexpr_No_Checks): New procedure (Duplicate_Subexpr_No_Checks_Orig): New procedure (Duplicate_Subexpr): Restore original form (checks duplicated) (Duplicate_Subexpr): Call Remove_Checks * exp_util.ads: (Duplicate_Subexpr_No_Checks): New procedure (Duplicate_Subexpr_No_Checks_Orig): New procedure Add 2002 to copyright notice * sem_util.adb: Use new Duplicate_Subexpr functions * sem_eval.adb: (Eval_Indexed_Component): This is the place to call Constant_Array_Ref and to replace the value. We simply merge the code of this function in here, since it is now no longer used elsewhere. This fixes the problem of the back end not realizing we were clever enough to see that this was constant. (Expr_Val): Remove call to Constant_Array_Ref (Expr_Rep_Val): Remove call to Constant_Array_Ref Minor reformatting (Constant_Array_Ref): Deal with string literals (patch suggested by Zack Weinberg on the gcc list) * exp_util.adb: Duplicate_Subexpr_No_Checks_Orig => Duplicate_Subexpr_Move_Checks. * exp_util.ads: Duplicate_Subexpr_No_Checks_Orig => Duplicate_Subexpr_Move_Checks. * sem_eval.adb: (Constant_Array_Ref): Verify that constant value of array exists before retrieving it (it may a private protected component in a function). From-SVN: r51513 --- gcc/ada/exp_util.adb | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'gcc/ada/exp_util.adb') diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index e998553..1acd0df 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -969,6 +969,42 @@ package body Exp_Util is return New_Copy_Tree (Exp); end Duplicate_Subexpr; + --------------------------------- + -- Duplicate_Subexpr_No_Checks -- + --------------------------------- + + function Duplicate_Subexpr_No_Checks + (Exp : Node_Id; + Name_Req : Boolean := False) + return Node_Id + is + New_Exp : Node_Id; + + begin + Remove_Side_Effects (Exp, Name_Req); + New_Exp := New_Copy_Tree (Exp); + Remove_Checks (New_Exp); + return New_Exp; + end Duplicate_Subexpr_No_Checks; + + ----------------------------------- + -- Duplicate_Subexpr_Move_Checks -- + ----------------------------------- + + function Duplicate_Subexpr_Move_Checks + (Exp : Node_Id; + Name_Req : Boolean := False) + return Node_Id + is + New_Exp : Node_Id; + + begin + Remove_Side_Effects (Exp, Name_Req); + New_Exp := New_Copy_Tree (Exp); + Remove_Checks (Exp); + return New_Exp; + end Duplicate_Subexpr_Move_Checks; + -------------------- -- Ensure_Defined -- -------------------- @@ -2310,7 +2346,8 @@ package body Exp_Util is Make_Op_Subtract (Loc, Left_Opnd => Make_Attribute_Reference (Loc, - Prefix => OK_Convert_To (T, Duplicate_Subexpr (E)), + Prefix => + OK_Convert_To (T, Duplicate_Subexpr_No_Checks (E)), Attribute_Name => Name_Size), Right_Opnd => Make_Attribute_Reference (Loc, @@ -2452,7 +2489,9 @@ package body Exp_Util is Utyp := Underlying_Type (Unc_Typ); Full_Subtyp := Make_Defining_Identifier (Loc, New_Internal_Name ('C')); - Full_Exp := Unchecked_Convert_To (Utyp, Duplicate_Subexpr (E)); + Full_Exp := + Unchecked_Convert_To + (Utyp, Duplicate_Subexpr_No_Checks (E)); Set_Parent (Full_Exp, Parent (E)); Priv_Subtyp := @@ -2490,13 +2529,14 @@ package body Exp_Util is Make_Range (Loc, Low_Bound => Make_Attribute_Reference (Loc, - Prefix => Duplicate_Subexpr (E), + Prefix => Duplicate_Subexpr_No_Checks (E), Attribute_Name => Name_First, Expressions => New_List ( Make_Integer_Literal (Loc, J))), + High_Bound => Make_Attribute_Reference (Loc, - Prefix => Duplicate_Subexpr (E), + Prefix => Duplicate_Subexpr_No_Checks (E), Attribute_Name => Name_Last, Expressions => New_List ( Make_Integer_Literal (Loc, J))))); @@ -2530,7 +2570,7 @@ package body Exp_Util is Append_To (List_Constr, Make_Selected_Component (Loc, - Prefix => Duplicate_Subexpr (E), + Prefix => Duplicate_Subexpr_No_Checks (E), Selector_Name => New_Reference_To (D, Loc))); Next_Discriminant (D); -- cgit v1.1