trans.c (Attribute_to_gnu): Strip conversions between original and packable version of types from the...

* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Size>: Strip
	conversions between original and packable version of types from
	the expression.

From-SVN: r151757
This commit is contained in:
Eric Botcazou 2009-09-16 15:02:25 +00:00 committed by Eric Botcazou
parent 721641c415
commit 20faffe76f
4 changed files with 50 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2009-09-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Size>: Strip
conversions between original and packable version of types from
the expression.
2009-09-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_field): Add DEBUG_INFO_P parameter.

View File

@ -1279,9 +1279,16 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
case Attr_Max_Size_In_Storage_Elements:
gnu_expr = gnu_prefix;
/* Remove NOPs from GNU_EXPR and conversions from GNU_PREFIX.
We only use GNU_EXPR to see if a COMPONENT_REF was involved. */
while (TREE_CODE (gnu_expr) == NOP_EXPR)
/* Remove NOPs and conversions between original and packable version
from GNU_EXPR, and conversions from GNU_PREFIX. We use GNU_EXPR
to see if a COMPONENT_REF was involved. */
while (TREE_CODE (gnu_expr) == NOP_EXPR
|| (TREE_CODE (gnu_expr) == VIEW_CONVERT_EXPR
&& TREE_CODE (TREE_TYPE (gnu_expr)) == RECORD_TYPE
&& TREE_CODE (TREE_TYPE (TREE_OPERAND (gnu_expr, 0)))
== RECORD_TYPE
&& TYPE_NAME (TREE_TYPE (gnu_expr))
== TYPE_NAME (TREE_TYPE (TREE_OPERAND (gnu_expr, 0)))))
gnu_expr = TREE_OPERAND (gnu_expr, 0);
gnu_prefix = remove_conversions (gnu_prefix, true);

View File

@ -1,3 +1,7 @@
2009-09-16 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/alignment9.adb: New test.
2009-09-16 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/discr20.ad[sb]: New test.

View File

@ -0,0 +1,30 @@
-- { dg-do run }
-- { dg-options "-gnatws" }
procedure Alignment9 is
type Kind is (Small, Large);
for Kind'Size use 8;
type Header is
record
K : Kind;
I : Integer;
end record;
for Header use
record
K at 4 range 0..7;
I at 0 range 0..31;
end record;
for Header'Size use 5*8;
for Header'Alignment use 1;
H : Header;
begin
if H'Size /= 40 then
raise Program_Error;
end if;
end;