+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.
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);
+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.
--- /dev/null
+-- { 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;