re PR tree-optimization/15262 ([tree-ssa] Alias analyzer cannot handle addressable fields)
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 Andrew Pinski <apinski@apple.com> * g++.dg/opt/pr14029.C: New test. * gcc.c-torture/execute/pr15262.c: New test. 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. From-SVN: r86396
This commit is contained in:
parent
35e0e58c7a
commit
9fc3b39aa9
|
@ -1,3 +1,11 @@
|
||||||
|
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>
|
2004-08-22 Richard Henderson <rth@redhat.com>
|
||||||
|
|
||||||
PR 17075
|
PR 17075
|
||||||
|
|
|
@ -2538,9 +2538,14 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
|
||||||
addr = fold (build2 (PLUS_EXPR, argtype,
|
addr = fold (build2 (PLUS_EXPR, argtype,
|
||||||
convert (argtype, addr),
|
convert (argtype, addr),
|
||||||
convert (argtype, byte_position (field))));
|
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
|
else
|
||||||
addr = build1 (code, argtype, arg);
|
addr = build1 (ADDR_EXPR, argtype, arg);
|
||||||
|
|
||||||
if (TREE_CODE (arg) == COMPOUND_LITERAL_EXPR)
|
if (TREE_CODE (arg) == COMPOUND_LITERAL_EXPR)
|
||||||
TREE_INVARIANT (addr) = TREE_CONSTANT (addr) = 1;
|
TREE_INVARIANT (addr) = TREE_CONSTANT (addr) = 1;
|
||||||
|
@ -6310,7 +6315,8 @@ c_finish_return (tree retval)
|
||||||
case ADDR_EXPR:
|
case ADDR_EXPR:
|
||||||
inner = TREE_OPERAND (inner, 0);
|
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);
|
inner = TREE_OPERAND (inner, 0);
|
||||||
|
|
||||||
if (DECL_P (inner)
|
if (DECL_P (inner)
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
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>
|
2004-08-20 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
PR c++/17121
|
PR c++/17121
|
||||||
|
|
|
@ -4123,6 +4123,11 @@ build_unary_op (enum tree_code code, tree xarg, int noconvert)
|
||||||
addr = fold (build2 (PLUS_EXPR, argtype, rval,
|
addr = fold (build2 (PLUS_EXPR, argtype, rval,
|
||||||
cp_convert (argtype,
|
cp_convert (argtype,
|
||||||
byte_position (field))));
|
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
|
if (TREE_CODE (argtype) == POINTER_TYPE
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
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>
|
2004-08-22 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
|
||||||
|
|
||||||
* gfortran.dg/reduction.f90: Add checks with complex arguments.
|
* gfortran.dg/reduction.f90: Add checks with complex arguments.
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
// { 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]);
|
||||||
|
};
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue