+2011-09-06 Ed Schonberg <schonberg@adacore.com>
+
+ * exp_ch4.adb (Expand_N_Case_Expression): Actions created for the
+ expression in a given case alternative must be attached to the
+ statement list of the ccrresponding case statement alternative
+ They cannot be propagated ahead of the case statement, because
+ the validity of the expression that generated the action may
+ hold only for that alternative.
+
+2011-09-06 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * exp_ch7.adb: Remove with and use clauses for Get_Targ.
+ (Alignment_Of): Remove the code for strict alignment targets.
+ (Double_Alignment_Of): Removed.
+ (Double_Size_Of): New routine.
+ (Make_Finalize_Address_Stmts): Change the
+ calculation of the dope's size. Update relevant comments.
+ (Size_Of): New routine.
+
2011-09-06 Steve Baird <baird@adacore.com>
* einfo.ads (Extra_Accessibility): Update associated comment to use
Alt := First (Alternatives (N));
while Present (Alt) loop
declare
- Aexp : Node_Id := Expression (Alt);
- Aloc : constant Source_Ptr := Sloc (Aexp);
+ Aexp : Node_Id := Expression (Alt);
+ Aloc : constant Source_Ptr := Sloc (Aexp);
+ Stats : List_Id;
begin
- -- Propagate declarations inserted in the node by Insert_Actions
- -- (for example, temporaries generated to remove side effects).
-
- Append_List_To (Actions, Sinfo.Actions (Alt));
+ -- As described above, take Unrestricted_Access for case of non-
+ -- scalar types, to avoid big copies, and special cases.
if not Is_Scalar_Type (Typ) then
Aexp :=
Attribute_Name => Name_Unrestricted_Access);
end if;
+ Stats := New_List (
+ Make_Assignment_Statement (Aloc,
+ Name => New_Occurrence_Of (Tnn, Loc),
+ Expression => Aexp));
+
+ -- Propagate declarations inserted in the node by Insert_Actions
+ -- (for example, temporaries generated to remove side effects).
+ -- These actions must remain attached to the alternative, given
+ -- that they are generated by the corresponding expression.
+
+ if Present (Sinfo.Actions (Alt)) then
+ Prepend_List (Sinfo.Actions (Alt), Stats);
+ end if;
+
Append_To
(Alternatives (Cstmt),
Make_Case_Statement_Alternative (Sloc (Alt),
Discrete_Choices => Discrete_Choices (Alt),
- Statements => New_List (
- Make_Assignment_Statement (Aloc,
- Name => New_Occurrence_Of (Tnn, Loc),
- Expression => Aexp))));
+ Statements => Stats));
end;
Next (Alt);
with Exp_Tss; use Exp_Tss;
with Exp_Util; use Exp_Util;
with Freeze; use Freeze;
-with Get_Targ; use Get_Targ;
with Lib; use Lib;
with Nlists; use Nlists;
with Nmake; use Nmake;
(Available_View (Designated_Type (Obj_Typ)))
and then Present (Expr)
and then
- (Is_Null_Access_BIP_Func_Call (Expr)
- or else (Is_Non_BIP_Func_Call (Expr)
- and then not
- Is_Related_To_Func_Return (Obj_Id)))
+ (Is_Null_Access_BIP_Func_Call (Expr)
+ or else
+ (Is_Non_BIP_Func_Call (Expr)
+ and then not Is_Related_To_Func_Return (Obj_Id)))
then
Processing_Actions (Has_No_Init => True);
--
-- Typ'Alignment
- function Double_Alignment_Of (Typ : Entity_Id) return Node_Id;
+ function Size_Of (Typ : Entity_Id) return Node_Id;
+ -- Subsidiary routine, generate the following attribute reference:
+ --
+ -- Typ'Size / Storage_Unit
+
+ function Double_Size_Of (Typ : Entity_Id) return Node_Id;
-- Subsidiary routine, generate the following expression:
--
- -- 2 * Typ'Alignment
+ -- 2 * Typ'Size / Storage_Unit
------------------
-- Alignment_Of --
function Alignment_Of (Typ : Entity_Id) return Node_Id is
begin
- -- Strict alignment targets such as SPARC ignore the alignment of the
- -- index type and use the system allocator alignment instead.
+ return
+ Make_Attribute_Reference (Loc,
+ Prefix => New_Reference_To (Typ, Loc),
+ Attribute_Name => Name_Alignment);
+ end Alignment_Of;
- if Target_Strict_Alignment then
- return Make_Integer_Literal (Loc, Get_System_Allocator_Alignment);
+ -------------
+ -- Size_Of --
+ -------------
- else
- return
- Make_Attribute_Reference (Loc,
- Prefix => New_Reference_To (Typ, Loc),
- Attribute_Name => Name_Alignment);
- end if;
- end Alignment_Of;
+ function Size_Of (Typ : Entity_Id) return Node_Id is
+ begin
+ return
+ Make_Op_Divide (Loc,
+ Left_Opnd =>
+ Make_Attribute_Reference (Loc,
+ Prefix => New_Reference_To (Typ, Loc),
+ Attribute_Name => Name_Size),
+ Right_Opnd =>
+ Make_Integer_Literal (Loc, System_Storage_Unit));
+ end Size_Of;
- -------------------------
- -- Double_Alignment_Of --
- -------------------------
+ --------------------
+ -- Double_Size_Of --
+ --------------------
- function Double_Alignment_Of (Typ : Entity_Id) return Node_Id is
+ function Double_Size_Of (Typ : Entity_Id) return Node_Id is
begin
return
Make_Op_Multiply (Loc,
Left_Opnd => Make_Integer_Literal (Loc, 2),
- Right_Opnd => Alignment_Of (Typ));
- end Double_Alignment_Of;
+ Right_Opnd => Size_Of (Typ));
+ end Double_Size_Of;
-- Start of processing for Make_Finalize_Address_Stmts
For_First := False;
-- Generate:
- -- 2 * Index_Typ'Alignment
+ -- 2 * Index_Typ'Size / Storage_Unit
- Dope_Expr := Double_Alignment_Of (Index_Typ);
+ Dope_Expr := Double_Size_Of (Index_Typ);
else
-- Generate:
- -- Dope_Expr + 2 * Index_Typ'Alignment
+ -- Dope_Expr + 2 * Index_Typ'Size / Storage_Unit
Dope_Expr :=
Make_Op_Add (Loc,
Left_Opnd => Dope_Expr,
- Right_Opnd => Double_Alignment_Of (Index_Typ));
+ Right_Opnd => Double_Size_Of (Index_Typ));
end if;
Next_Index (Index);
end loop;
- -- Round the cumulative alignment to the next higher multiple of
- -- the array alignment. Generate:
+ -- Dope_Expr calculates the optimum size of the dope, as if the
+ -- dope was "packed". Since the alignment of the component type
+ -- dictates the underlying layout of the array, round the size
+ -- of the dope to the next higher multiple of the component
+ -- alignment. Generate:
- -- ((Dope_Expr + Typ'Alignment - 1) / Typ'Alignment)
- -- * Typ'Alignment
+ -- ((Dope_Expr + Typ'Alignment - 1) / Typ'Alignment) *
+ -- Typ'Alignment
Dope_Expr :=
Make_Op_Multiply (Loc,