OSDN Git Service

gcc/:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Oct 2010 13:39:37 +0000 (13:39 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 26 Oct 2010 13:39:37 +0000 (13:39 +0000)
PR middle-end/45687
* ipa-prop.c (ipa_modify_call_arguments): Correct type of MEM_REF
offset.
gcc/testsuite:
* gcc.c-torture/execute/20101025-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165964 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ipa-prop.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20101025-1.c [new file with mode: 0644]

index 949fb10..1e329e2 100644 (file)
@@ -1,3 +1,9 @@
+2010-10-26  Ian Lance Taylor  <iant@google.com>
+
+       PR middle-end/45687
+       * ipa-prop.c (ipa_modify_call_arguments): Correct type of MEM_REF
+       offset.
+
 2010-10-25  Rodrigo Rivas Costa <rodrigorivascosta@gmail.com>
 
        Implement opaque-enum-specifiesr for C++0x
index 9ffbb3f..b3d9f91 100644 (file)
@@ -2186,7 +2186,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
 
          if (TREE_CODE (base) == ADDR_EXPR
              && DECL_P (TREE_OPERAND (base, 0)))
-           off = build_int_cst (reference_alias_ptr_type (base),
+           off = build_int_cst (TREE_TYPE (base),
                                 adj->offset / BITS_PER_UNIT);
          else if (TREE_CODE (base) != ADDR_EXPR
                   && POINTER_TYPE_P (TREE_TYPE (base)))
@@ -2209,7 +2209,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
                }
              else if (TREE_CODE (base) == MEM_REF)
                {
-                 off = build_int_cst (TREE_TYPE (TREE_OPERAND (base,1)),
+                 off = build_int_cst (TREE_TYPE (TREE_OPERAND (base, 1)),
                                       base_offset
                                       + adj->offset / BITS_PER_UNIT);
                  off = int_const_binop (PLUS_EXPR, TREE_OPERAND (base, 1),
@@ -2218,7 +2218,7 @@ ipa_modify_call_arguments (struct cgraph_edge *cs, gimple stmt,
                }
              else
                {
-                 off = build_int_cst (reference_alias_ptr_type (base),
+                 off = build_int_cst (reference_alias_ptr_type (prev_base),
                                       base_offset
                                       + adj->offset / BITS_PER_UNIT);
                  base = build_fold_addr_expr (base);
index 5eb2f5c..a29194f 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-26  Ian Lance Taylor  <iant@google.com>
+
+       PR middle-end/45687
+       * gcc.c-torture/execute/20101025-1.c: New test.
+
 2010-10-26  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/45451
diff --git a/gcc/testsuite/gcc.c-torture/execute/20101025-1.c b/gcc/testsuite/gcc.c-torture/execute/20101025-1.c
new file mode 100644 (file)
index 0000000..95361a9
--- /dev/null
@@ -0,0 +1,30 @@
+static int g_7;
+static int *volatile g_6 = &g_7;
+int g_3;
+
+static int f1 (int *p_58)
+{
+    return *p_58;
+}
+
+void f2 (int i) __attribute__ ((noinline));
+void f2 (int i)
+{
+  g_3 = i;
+}
+
+int f3 (void) __attribute__ ((noinline));
+int f3 (void)
+{
+    *g_6 = 1;
+    f2 (f1 (&g_7));
+    return 0;
+}
+
+int main ()
+{
+  f3 ();
+  if (g_3 != 1)
+    abort ();
+  exit (0);
+}