+2011-06-16 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/49343
+ * tree-sra.c (build_ref_for_model): Use component_ref_field_offset to
+ calculate offset, provide 2nd operand for the new COMPONENT_REF.
+
2011-06-16 Iain Sandoe <iains@gcc.gnu.org>
* config/darwin-protos.h (machopic_select_rtx_section): Move to
+2011-06-16 Martin Jambor <mjambor@suse.cz>
+
+ PR tree-optimization/49343
+ * gnat.dg/discr31.adb: New test.
+ * gnat.dg/discr31.ads: Likewise.
+
2011-06-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/debug/pr49032.c: Prune mips-tfile warning.
--- /dev/null
+package Discr31 is
+
+ type Byte_List_Type is array(Positive range <>) of Integer;
+
+ type Log_Item_Type(Last : Natural) is record
+ Data : Byte_List_Type(1 .. Last) := (others => 0);
+ Link : Natural := 0;
+ end record;
+
+ type Packet_Data_Type is access Log_Item_Type;
+
+ function Log_Item(Packet : in Packet_Data_Type) return Log_Item_Type;
+
+end Discr31;
{
if (TREE_CODE (model->expr) == COMPONENT_REF)
{
- tree t, exp_type;
- offset -= int_bit_position (TREE_OPERAND (model->expr, 1));
+ tree t, exp_type, fld = TREE_OPERAND (model->expr, 1);
+ tree cr_offset = component_ref_field_offset (model->expr);
+
+ gcc_assert (cr_offset && host_integerp (cr_offset, 1));
+ offset -= TREE_INT_CST_LOW (cr_offset) * BITS_PER_UNIT;
+ offset -= TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (fld));
exp_type = TREE_TYPE (TREE_OPERAND (model->expr, 0));
t = build_ref_for_offset (loc, base, offset, exp_type, gsi, insert_after);
- return fold_build3_loc (loc, COMPONENT_REF, model->type, t,
- TREE_OPERAND (model->expr, 1), NULL_TREE);
+ return fold_build3_loc (loc, COMPONENT_REF, model->type, t, fld,
+ TREE_OPERAND (model->expr, 2));
}
else
return build_ref_for_offset (loc, base, offset, model->type,