Commit dc9111cf by Eric Botcazou Committed by Arnaud Charlet

freeze.adb (Check_Component_Storage_Order): Skip a record component if it has…

freeze.adb (Check_Component_Storage_Order): Skip a record component if it has Complex_Representation.

2015-10-26  Eric Botcazou  <ebotcazou@adacore.com>

	* freeze.adb (Check_Component_Storage_Order): Skip a record
	component if it has Complex_Representation.
	(Freeze_Record_Type): If the type has Complex_Representation, skip the
	regular treatment of Scalar_Storage_Order attribute and instead issue
	a warning if it is present.

From-SVN: r229325
parent 930e85a3
2015-10-26 Eric Botcazou <ebotcazou@adacore.com>
* freeze.adb (Check_Component_Storage_Order): Skip a record
component if it has Complex_Representation.
(Freeze_Record_Type): If the type has Complex_Representation, skip the
regular treatment of Scalar_Storage_Order attribute and instead issue
a warning if it is present.
2015-10-26 Bob Duff <duff@adacore.com> 2015-10-26 Bob Duff <duff@adacore.com>
* sem_ch13.adb (Check_Iterator_Functions): For a Default_Iterator * sem_ch13.adb (Check_Iterator_Functions): For a Default_Iterator
......
...@@ -1197,9 +1197,14 @@ package body Freeze is ...@@ -1197,9 +1197,14 @@ package body Freeze is
Attribute_Scalar_Storage_Order); Attribute_Scalar_Storage_Order);
Comp_ADC_Present := Present (Comp_ADC); Comp_ADC_Present := Present (Comp_ADC);
-- Case of record or array component: check storage order compatibility -- Case of record or array component: check storage order compatibility.
-- But, if the record has Complex_Representation, then it is treated as
-- a scalar in the back end so the storage order is irrelevant.
if Is_Record_Type (Comp_Type) or else Is_Array_Type (Comp_Type) then if (Is_Record_Type (Comp_Type)
and then not Has_Complex_Representation (Comp_Type))
or else Is_Array_Type (Comp_Type)
then
Comp_SSO_Differs := Comp_SSO_Differs :=
Reverse_Storage_Order (Encl_Type) Reverse_Storage_Order (Encl_Type)
/= /=
...@@ -3940,61 +3945,74 @@ package body Freeze is ...@@ -3940,61 +3945,74 @@ package body Freeze is
Next_Entity (Comp); Next_Entity (Comp);
end loop; end loop;
-- Deal with default setting of reverse storage order SSO_ADC :=
Get_Attribute_Definition_Clause
(Rec, Attribute_Scalar_Storage_Order);
Set_SSO_From_Default (Rec); -- If the record type has Complex_Representation, then it is treated
-- as a scalar in the back end so the storage order is irrelevant.
-- Check consistent attribute setting on component types if Has_Complex_Representation (Rec) then
if Present (SSO_ADC) then
Error_Msg_N
("??storage order has no effect with Complex_Representation",
SSO_ADC);
end if;
SSO_ADC := Get_Attribute_Definition_Clause else
(Rec, Attribute_Scalar_Storage_Order); -- Deal with default setting of reverse storage order
declare Set_SSO_From_Default (Rec);
Comp_ADC_Present : Boolean;
begin -- Check consistent attribute setting on component types
Comp := First_Component (Rec);
while Present (Comp) loop declare
Check_Component_Storage_Order Comp_ADC_Present : Boolean;
(Encl_Type => Rec, begin
Comp => Comp, Comp := First_Component (Rec);
ADC => SSO_ADC, while Present (Comp) loop
Comp_ADC_Present => Comp_ADC_Present); Check_Component_Storage_Order
SSO_ADC_Component := SSO_ADC_Component or Comp_ADC_Present; (Encl_Type => Rec,
Next_Component (Comp); Comp => Comp,
end loop; ADC => SSO_ADC,
end; Comp_ADC_Present => Comp_ADC_Present);
SSO_ADC_Component := SSO_ADC_Component or Comp_ADC_Present;
Next_Component (Comp);
end loop;
end;
-- Now deal with reverse storage order/bit order issues -- Now deal with reverse storage order/bit order issues
if Present (SSO_ADC) then if Present (SSO_ADC) then
-- Check compatibility of Scalar_Storage_Order with Bit_Order, if -- Check compatibility of Scalar_Storage_Order with Bit_Order,
-- the former is specified. -- if the former is specified.
if Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec) then if Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec) then
-- Note: report error on Rec, not on SSO_ADC, as ADC may apply -- Note: report error on Rec, not on SSO_ADC, as ADC may
-- to some ancestor type. -- apply to some ancestor type.
Error_Msg_Sloc := Sloc (SSO_ADC); Error_Msg_Sloc := Sloc (SSO_ADC);
Error_Msg_N Error_Msg_N
("scalar storage order for& specified# inconsistent with " ("scalar storage order for& specified# inconsistent with "
& "bit order", Rec); & "bit order", Rec);
end if; end if;
-- Warn if there is an Scalar_Storage_Order attribute definition -- Warn if there is a Scalar_Storage_Order attribute definition
-- clause but no component clause, no component that itself has -- clause but no component clause, no component that itself has
-- such an attribute definition, and no pragma Pack. -- such an attribute definition, and no pragma Pack.
if not (Placed_Component if not (Placed_Component
or else or else
SSO_ADC_Component SSO_ADC_Component
or else or else
Is_Packed (Rec)) Is_Packed (Rec))
then then
Error_Msg_N Error_Msg_N
("??scalar storage order specified but no component clause", ("??scalar storage order specified but no component "
SSO_ADC); & "clause", SSO_ADC);
end if;
end if; end if;
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