+2004-08-22 Andrew Pinski <apinski@apple.com>
+
+ PR c/15262
+ * c-typeck.c (build_unary_op): Use &a.b if the foldded lowered
+ expression is not constant.
+ (c_finish_return): Do not go through INDIRECT_REF when looking
+ for the inner expression of an ADDR_EXPR for warning about.
+
2004-08-22 Richard Henderson <rth@redhat.com>
PR 17075
addr = fold (build2 (PLUS_EXPR, argtype,
convert (argtype, addr),
convert (argtype, byte_position (field))));
+
+ /* If the folded PLUS_EXPR is not a constant address, wrap
+ it in an ADDR_EXPR. */
+ if (!TREE_CONSTANT (addr))
+ addr = build1 (ADDR_EXPR, argtype, arg);
}
else
- addr = build1 (code, argtype, arg);
+ addr = build1 (ADDR_EXPR, argtype, arg);
if (TREE_CODE (arg) == COMPOUND_LITERAL_EXPR)
TREE_INVARIANT (addr) = TREE_CONSTANT (addr) = 1;
case ADDR_EXPR:
inner = TREE_OPERAND (inner, 0);
- while (TREE_CODE_CLASS (TREE_CODE (inner)) == 'r')
+ while (TREE_CODE_CLASS (TREE_CODE (inner)) == 'r'
+ && TREE_CODE (inner) != INDIRECT_REF)
inner = TREE_OPERAND (inner, 0);
if (DECL_P (inner)
+2004-08-22 Andrew Pinski <apinski@apple.com>
+
+ PR c++/14029
+ * typeck.c (build_unary_op): Use &a.b if the foldded lowered
+ expression is not constant.
+
2004-08-20 Mark Mitchell <mark@codesourcery.com>
PR c++/17121
addr = fold (build2 (PLUS_EXPR, argtype, rval,
cp_convert (argtype,
byte_position (field))));
+
+ /* If the folded PLUS_EXPR is not a constant address, wrap
+ it in an ADDR_EXPR. */
+ if (!TREE_CONSTANT (addr))
+ addr = build_address (arg);
}
if (TREE_CODE (argtype) == POINTER_TYPE
+2004-08-22 Andrew Pinski <apinski@apple.com>
+
+ * g++.dg/opt/pr14029.C: New test.
+ * gcc.c-torture/execute/pr15262.c: New test.
+
2004-08-22 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* gfortran.dg/reduction.f90: Add checks with complex arguments.
--- /dev/null
+// { dg-do run }
+// { dg-options "-O2" }
+// We used to mis-compile this testcase as we did not know that
+// &a+offsetof(b,a) was the same as &a.b
+
+struct Iterator {
+ int * ptr;
+
+ Iterator(int * i) : ptr(i) { }
+ void operator++() { ++ptr; }
+ int *const & base() const { return ptr; }
+};
+
+
+Iterator find_7(Iterator first, Iterator last)
+{
+ int trip_count = (last.base() - first.base()) >> 1;
+
+ for ( ; trip_count > 0 ; --trip_count) {
+ if (*first.ptr == 7) return first;
+ ++first;
+
+ if (*first.ptr == 7) return first;
+ ++first;
+ }
+
+ switch(last.base() - first.base()) {
+ case 1:
+ if (*first.ptr == 7) return first;
+ ++first;
+ case 0:
+ default:
+ return last;
+ }
+}
+
+int main() {
+ int as[5] = {4,4,4,4,7};
+ return (find_7(Iterator(&as[0]), Iterator(&as[5])).ptr == &as[5]);
+};
+
--- /dev/null
+/* We used to mis-compile this testcase as we did not know that
+ &a+offsetof(b,a) was the same as &a.b */
+struct A
+{
+ int t;
+ int i;
+};
+
+void
+bar (float *p)
+{
+ *p = 5.2;
+}
+
+int
+foo(struct A *locp, int i, int str)
+{
+ float f, g, *p;
+ int T355;
+ int *T356;
+ /* Currently, the alias analyzer has limited support for handling
+ aliases of structure fields when no other variables are aliased.
+ Introduce additional aliases to confuse it. */
+ p = i ? &g : &f;
+ bar (p);
+ if (*p > 0.0)
+ str = 1;
+
+ T355 = locp->i;
+ T356 = &locp->i;
+ *T356 = str;
+ T355 = locp->i;
+
+ return T355;
+}
+
+main ()
+{
+ struct A loc;
+ int str;
+
+ loc.i = 2;
+ str = foo (&loc, 10, 3);
+ if (str!=1)
+ abort ();
+ return 0;
+}
+