Commit b1a785fb by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): Adjust call to components_to_record.

	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Adjust
	call to components_to_record.
	(components_to_record): Add FIRST_FREE_POS parameter.  For the variant
	part, reuse enclosing union even if there is a representation clause
	on the Unchecked_Union.  If there is a variant part, compute the new
	first free position, if any.  Adjust call to self.  Use a single field
	directly only if it hasn't got a representation clause or is placed at
	offset zero.  Create the variant part at offset 0 if all the fields
	down to this level have a rep clause.  Do not chain the variant part
	immediately and adjust downstream.
	Do not test ALL_REP before moving the fields without rep clause to the
	previous level.  Call create_rep_part to create the REP part and force
	a minimum size on it if necessary.  Do not chain it immediately.
	Create a fake REP part if there are fields without rep clause that need
	to be laid out starting from FIRST_FREE_POS.
	At the end, chain the REP part and then the variant part.
	(create_rep_part): New function.
	(get_rep_part): Minor tweak.
	* gcc-interface/utils.c (tree_code_for_record_type): Minor tweak.

From-SVN: r181526
parent 40760111
2011-11-20 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: Adjust
call to components_to_record.
(components_to_record): Add FIRST_FREE_POS parameter. For the variant
part, reuse enclosing union even if there is a representation clause
on the Unchecked_Union. If there is a variant part, compute the new
first free position, if any. Adjust call to self. Use a single field
directly only if it hasn't got a representation clause or is placed at
offset zero. Create the variant part at offset 0 if all the fields
down to this level have a rep clause. Do not chain the variant part
immediately and adjust downstream.
Do not test ALL_REP before moving the fields without rep clause to the
previous level. Call create_rep_part to create the REP part and force
a minimum size on it if necessary. Do not chain it immediately.
Create a fake REP part if there are fields without rep clause that need
to be laid out starting from FIRST_FREE_POS.
At the end, chain the REP part and then the variant part.
(create_rep_part): New function.
(get_rep_part): Minor tweak.
* gcc-interface/utils.c (tree_code_for_record_type): Minor tweak.
2011-11-18 Iain Sandoe <iains@gcc.gnu.org> 2011-11-18 Iain Sandoe <iains@gcc.gnu.org>
PR target/50678 PR target/50678
......
...@@ -4744,19 +4744,17 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) ...@@ -4744,19 +4744,17 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
enum tree_code enum tree_code
tree_code_for_record_type (Entity_Id gnat_type) tree_code_for_record_type (Entity_Id gnat_type)
{ {
Node_Id component_list Node_Id component_list, component;
= Component_List (Type_Definition
(Declaration_Node
(Implementation_Base_Type (gnat_type))));
Node_Id component;
/* Make this a UNION_TYPE unless it's either not an Unchecked_Union or
we have a non-discriminant field outside a variant. In either case,
it's a RECORD_TYPE. */
/* Return UNION_TYPE if it's an Unchecked_Union whose non-discriminant
fields are all in the variant part. Otherwise, return RECORD_TYPE. */
if (!Is_Unchecked_Union (gnat_type)) if (!Is_Unchecked_Union (gnat_type))
return RECORD_TYPE; return RECORD_TYPE;
gnat_type = Implementation_Base_Type (gnat_type);
component_list
= Component_List (Type_Definition (Declaration_Node (gnat_type)));
for (component = First_Non_Pragma (Component_Items (component_list)); for (component = First_Non_Pragma (Component_Items (component_list));
Present (component); Present (component);
component = Next_Non_Pragma (component)) component = Next_Non_Pragma (component))
......
2011-11-20 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr32.adb: New test.
* gnat.dg/discr32_pkg.ads: New helper.
2011-11-20 Nathan Sidwell <nathan@acm.org> 2011-11-20 Nathan Sidwell <nathan@acm.org>
PR gcov-profile/51113 PR gcov-profile/51113
......
-- { dg-do run }
-- { dg-options "-gnatws" }
with Discr32_Pkg; use Discr32_Pkg;
procedure Discr32 is
begin
if R1'Object_Size /= 32 then
raise Program_Error;
end if;
if R2'Object_Size /= R'Object_Size then
raise Program_Error;
end if;
if R3'Object_Size /= 64 then
raise Program_Error;
end if;
end;
package Discr32_Pkg is
type Enum is (One, Two, Three);
type R (D : Enum) is record
case D is
when One => B : Boolean;
when Two => I : Integer;
when Three => F : Float;
end case;
end record;
for R use record
D at 0 range 0 .. 1;
B at 1 range 0 .. 0;
I at 4 range 0 .. 31 + 128;
-- F at 4 range 0 .. 31;
end record;
subtype R1 is R (One);
subtype R2 is R (Two);
subtype R3 is R (Three);
end Discr32_Pkg;
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