Commit 50cd5b4d by Arnaud Charlet

[multiple changes]

2012-04-26  Robert Dewar  <dewar@adacore.com>

	* sem_util.adb: Minor reformatting.

2012-04-26  Thomas Quinot  <quinot@adacore.com>

	* exp_aggr.adb, exp_pakd.adb (Setup_Inline_Packed_Array_Reference,
	Packed_Array_Aggregate_Handled.Get_Component_Val):
	Reverse bit numbering within PAT when Reverse_Storage_Order
	applies to the enclosing record.

2012-04-26  Thomas Quinot  <quinot@adacore.com>

	* freeze.adb (Freeze_Record_Type): Improve error message for
	Scalar_Storage_Order inconsistent with Bit_Order.

From-SVN: r186865
parent 851634c7
2012-04-26 Robert Dewar <dewar@adacore.com>
* sem_util.adb: Minor reformatting.
2012-04-26 Thomas Quinot <quinot@adacore.com>
* exp_aggr.adb, exp_pakd.adb (Setup_Inline_Packed_Array_Reference,
Packed_Array_Aggregate_Handled.Get_Component_Val):
Reverse bit numbering within PAT when Reverse_Storage_Order
applies to the enclosing record.
2012-04-26 Thomas Quinot <quinot@adacore.com>
* freeze.adb (Freeze_Record_Type): Improve error message for
Scalar_Storage_Order inconsistent with Bit_Order.
2012-04-25 Gary Dismukes <dismukes@adacore.com> 2012-04-25 Gary Dismukes <dismukes@adacore.com>
* exp_ch9.adb: Add comments on the usage of the * exp_ch9.adb: Add comments on the usage of the
......
...@@ -6077,12 +6077,43 @@ package body Exp_Aggr is ...@@ -6077,12 +6077,43 @@ package body Exp_Aggr is
Expr : Node_Id; Expr : Node_Id;
-- Next expression from positional parameters of aggregate -- Next expression from positional parameters of aggregate
Enclosing_Aggregate : Node_Id;
In_Reverse_Storage_Order_Record : Boolean;
-- True if we are within an aggregate of a record type with
-- reversed storage order.
begin begin
-- Determine whether we are in a reversed storage order record
-- aggregate.
In_Reverse_Storage_Order_Record := False;
Enclosing_Aggregate := Parent (N);
while Present (Enclosing_Aggregate) loop
if Nkind (Enclosing_Aggregate) = N_Component_Association then
null;
elsif Nkind (Enclosing_Aggregate) /= N_Aggregate then
exit;
elsif Is_Record_Type (Etype (Enclosing_Aggregate))
and then Reverse_Storage_Order
(Etype (Enclosing_Aggregate))
then
In_Reverse_Storage_Order_Record := True;
exit;
end if;
Enclosing_Aggregate := Parent (Enclosing_Aggregate);
end loop;
-- For little endian, we fill up the low order bits of the target -- For little endian, we fill up the low order bits of the target
-- value. For big endian we fill up the high order bits of the -- value. For big endian we fill up the high order bits of the
-- target value (which is a left justified modular value). -- target value (which is a left justified modular value).
if Bytes_Big_Endian xor Debug_Flag_8 then if Bytes_Big_Endian
xor Debug_Flag_8
xor In_Reverse_Storage_Order_Record
then
Shift := Csiz * (Len - 1); Shift := Csiz * (Len - 1);
Incr := -Csiz; Incr := -Csiz;
else else
......
...@@ -1280,12 +1280,12 @@ package body Exp_Pakd is ...@@ -1280,12 +1280,12 @@ package body Exp_Pakd is
-- Initially Rhs is the right hand side value, it will be replaced -- Initially Rhs is the right hand side value, it will be replaced
-- later by an appropriate unchecked conversion for the assignment. -- later by an appropriate unchecked conversion for the assignment.
Obj : Node_Id; Obj : Node_Id;
Atyp : Entity_Id; Atyp : Entity_Id;
PAT : Entity_Id; PAT : Entity_Id;
Ctyp : Entity_Id; Ctyp : Entity_Id;
Csiz : Int; Csiz : Int;
Cmask : Uint; Cmask : Uint;
Shift : Node_Id; Shift : Node_Id;
-- The expression for the shift value that is required -- The expression for the shift value that is required
...@@ -1433,9 +1433,9 @@ package body Exp_Pakd is ...@@ -1433,9 +1433,9 @@ package body Exp_Pakd is
Rhs_Val := Expr_Rep_Value (Rhs); Rhs_Val := Expr_Rep_Value (Rhs);
Rhs_Val_Known := True; Rhs_Val_Known := True;
-- The following test catches the case of an unchecked conversion -- The following test catches the case of an unchecked conversion of
-- of an integer literal. This results from optimizing aggregates -- an integer literal. This results from optimizing aggregates of
-- of packed types. -- packed types.
elsif Nkind (Rhs) = N_Unchecked_Type_Conversion elsif Nkind (Rhs) = N_Unchecked_Type_Conversion
and then Compile_Time_Known_Value (Expression (Rhs)) and then Compile_Time_Known_Value (Expression (Rhs))
...@@ -2619,11 +2619,16 @@ package body Exp_Pakd is ...@@ -2619,11 +2619,16 @@ package body Exp_Pakd is
Cmask : out Uint; Cmask : out Uint;
Shift : out Node_Id) Shift : out Node_Id)
is is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
PAT : Entity_Id; PAT : Entity_Id;
Otyp : Entity_Id; Otyp : Entity_Id;
Csiz : Uint; Pref : Node_Id;
Osiz : Uint; Csiz : Uint;
Osiz : Uint;
In_Reverse_Storage_Order_Record : Boolean;
-- Set True if Obj is a [sub]component of a record that has reversed
-- scalar storage order.
begin begin
Csiz := Component_Size (Atyp); Csiz := Component_Size (Atyp);
...@@ -2658,7 +2663,7 @@ package body Exp_Pakd is ...@@ -2658,7 +2663,7 @@ package body Exp_Pakd is
if Csiz /= 1 then if Csiz /= 1 then
Shift := Shift :=
Make_Op_Multiply (Loc, Make_Op_Multiply (Loc,
Left_Opnd => Make_Integer_Literal (Loc, Csiz), Left_Opnd => Make_Integer_Literal (Loc, Csiz),
Right_Opnd => Shift); Right_Opnd => Shift);
end if; end if;
...@@ -2693,7 +2698,7 @@ package body Exp_Pakd is ...@@ -2693,7 +2698,7 @@ package body Exp_Pakd is
Prefix => Obj, Prefix => Obj,
Expressions => New_List ( Expressions => New_List (
Make_Op_Divide (Loc, Make_Op_Divide (Loc,
Left_Opnd => Duplicate_Subexpr (Shift), Left_Opnd => Duplicate_Subexpr (Shift),
Right_Opnd => Make_Integer_Literal (Loc, Osiz)))); Right_Opnd => Make_Integer_Literal (Loc, Osiz))));
Shift := New_Shift; Shift := New_Shift;
...@@ -2725,7 +2730,30 @@ package body Exp_Pakd is ...@@ -2725,7 +2730,30 @@ package body Exp_Pakd is
-- the array used to implement the packed array, F is the number of bits -- the array used to implement the packed array, F is the number of bits
-- in a source array element, and Shift is the count so far computed. -- in a source array element, and Shift is the count so far computed.
if Bytes_Big_Endian then -- We also have to adjust if the storage order is reversed
Pref := Obj;
loop
case Nkind (Pref) is
when N_Selected_Component =>
Pref := Prefix (Pref);
exit;
when N_Indexed_Component =>
Pref := Prefix (Pref);
when others =>
Pref := Empty;
exit;
end case;
end loop;
In_Reverse_Storage_Order_Record :=
Present (Pref)
and then Is_Record_Type (Etype (Pref))
and then Reverse_Storage_Order (Etype (Pref));
if Bytes_Big_Endian xor In_Reverse_Storage_Order_Record then
Shift := Shift :=
Make_Op_Subtract (Loc, Make_Op_Subtract (Loc,
Left_Opnd => Make_Integer_Literal (Loc, Osiz - Csiz), Left_Opnd => Make_Integer_Literal (Loc, Osiz - Csiz),
......
...@@ -2138,15 +2138,13 @@ package body Freeze is ...@@ -2138,15 +2138,13 @@ package body Freeze is
if Present (ADC) if Present (ADC)
and then Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec) and then Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec)
then then
if Bytes_Big_Endian = not Reverse_Storage_Order (Rec) then -- Note: report error on Rec, not on ADC, as ADC may apply to
Error_Msg_N -- an ancestor type.
("Scalar_Storage_Order High_Order_First is inconsistent with"
& " Bit_Order", ADC); Error_Msg_Sloc := Sloc (ADC);
else Error_Msg_N
Error_Msg_N ("scalar storage order for& specified# inconsistent with "
("Scalar_Storage_Order Low_Order_First is inconsistent with" & "its bit order", Rec);
& " Bit_Order", ADC);
end if;
end if; end if;
-- Deal with Bit_Order aspect specifying a non-default bit order -- Deal with Bit_Order aspect specifying a non-default bit order
......
...@@ -1236,9 +1236,7 @@ package body Sem_Util is ...@@ -1236,9 +1236,7 @@ package body Sem_Util is
-- Loop through sequence of basic declarative items -- Loop through sequence of basic declarative items
Outer : while Present (Decl) loop Outer : while Present (Decl) loop
if Nkind (Decl) /= N_Subprogram_Body if not Nkind_In (Decl, N_Subprogram_Body, N_Package_Body, N_Task_Body)
and then Nkind (Decl) /= N_Package_Body
and then Nkind (Decl) /= N_Task_Body
and then Nkind (Decl) not in N_Body_Stub and then Nkind (Decl) not in N_Body_Stub
then then
Next (Decl); Next (Decl);
...@@ -3577,15 +3575,15 @@ package body Sem_Util is ...@@ -3577,15 +3575,15 @@ package body Sem_Util is
Enclosing_Subp : constant Node_Id := Enclosing_Subprogram (Def_Id); Enclosing_Subp : constant Node_Id := Enclosing_Subprogram (Def_Id);
Enclosing_Pack : constant Node_Id := Enclosing_Package (Def_Id); Enclosing_Pack : constant Node_Id := Enclosing_Package (Def_Id);
Other_Scope : constant Node_Id := Enclosing_Dynamic_Scope (C); Other_Scope : constant Node_Id := Enclosing_Dynamic_Scope (C);
begin
begin
-- ... unless the new declaration is in a subprogram, and the -- ... unless the new declaration is in a subprogram, and the
-- visible declaration is a variable declaration or a parameter -- visible declaration is a variable declaration or a parameter
-- specification outside that subprogram. -- specification outside that subprogram.
if Present (Enclosing_Subp) if Present (Enclosing_Subp)
and then Nkind_In (Parent (C), N_Object_Declaration, and then Nkind_In (Parent (C), N_Object_Declaration,
N_Parameter_Specification) N_Parameter_Specification)
and then not Scope_Within_Or_Same (Other_Scope, Enclosing_Subp) and then not Scope_Within_Or_Same (Other_Scope, Enclosing_Subp)
then then
null; null;
...@@ -7595,13 +7593,13 @@ package body Sem_Util is ...@@ -7595,13 +7593,13 @@ package body Sem_Util is
-------------------------------------- --------------------------------------
function Is_Internally_Generated_Renaming (N : Node_Id) return Boolean is function Is_Internally_Generated_Renaming (N : Node_Id) return Boolean is
P : Node_Id := N; P : Node_Id;
begin begin
P := N;
while Present (P) loop while Present (P) loop
if Nkind (P) = N_Object_Renaming_Declaration then if Nkind (P) = N_Object_Renaming_Declaration then
return not Comes_From_Source (P); return not Comes_From_Source (P);
elsif Is_List_Member (P) then elsif Is_List_Member (P) then
return False; return False;
end if; end if;
...@@ -11659,9 +11657,11 @@ package body Sem_Util is ...@@ -11659,9 +11657,11 @@ package body Sem_Util is
------------------------ ------------------------
function Proper_First_Index (Array_Typ : Entity_Id) return Entity_Id is function Proper_First_Index (Array_Typ : Entity_Id) return Entity_Id is
Typ : Entity_Id := Array_Typ; Typ : Entity_Id;
begin begin
Typ := Array_Typ;
if Ekind (Typ) = E_String_Literal_Subtype then if Ekind (Typ) = E_String_Literal_Subtype then
Typ := Base_Type (Typ); Typ := Base_Type (Typ);
end if; end if;
......
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