OSDN Git Service

PR target/50350
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Oct 2011 08:45:45 +0000 (08:45 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Oct 2011 08:45:45 +0000 (08:45 +0000)
Backport from mainline
2011-09-27  Richard Sandiford  <rdsandiford@googlemail.com>

PR middle-end/50386
PR middle-end/50326
* tree-sra.c (build_ref_for_model): Use the type of the field as
the type of the COMPONENT_REF.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@180179 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-sra.c

index 95bd52f..016e518 100644 (file)
@@ -1,3 +1,14 @@
+2011-10-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/50350
+       Backport from mainline
+       2011-09-27  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       PR middle-end/50386
+       PR middle-end/50326
+       * tree-sra.c (build_ref_for_model): Use the type of the field as
+       the type of the COMPONENT_REF.
+
 2011-10-18  Uros Bizjak  <ubizjak@gmail.com>
            Eric Botcazou  <ebotcazou@adacore.com>
 
index 9cce470..1195af9 100644 (file)
@@ -1448,12 +1448,12 @@ build_ref_for_model (location_t loc, tree base, HOST_WIDE_INT offset,
 {
   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);
+      offset -= int_bit_position (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, TREE_TYPE (fld), t, fld,
+                             NULL_TREE);
     }
   else
     return build_ref_for_offset (loc, base, offset, model->type,