2006-09-16 Andrew Pinski PR tree-opt/29059 * tree-ssa-propagate.c (set_rhs): Reject MODIFY_EXPR right away for the expr argument. * gcc.c-torture/compile/strcpy-1.c: New test. * gcc.c-torture/compile/strcpy-2.c: New test. * gcc.c-torture/compile/memcpy-1.c: New test. * gcc.c-torture/compile/memcpy-2.c: New test. --- gcc/tree-ssa-propagate.c (revision 116996) +++ gcc/tree-ssa-propagate.c (revision 116997) @@ -588,7 +588,8 @@ set_rhs (tree *stmt_p, tree expr) && !is_gimple_val (TREE_OPERAND (TREE_OPERAND (expr, 0), 1))) return false; } - else if (code == COMPOUND_EXPR) + else if (code == COMPOUND_EXPR + || code == MODIFY_EXPR) return false; switch (TREE_CODE (stmt)) --- gcc/testsuite/gcc.c-torture/compile/strcpy-1.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/strcpy-1.c (revision 116997) @@ -0,0 +1,15 @@ + + +typedef struct +{ + char str[20]; +}STACK; +STACK stack[15]; +int level; +rezero () +{ + level = 0; + __builtin_strcpy (stack[level].str, ""); +} + + --- gcc/testsuite/gcc.c-torture/compile/strcpy-2.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/strcpy-2.c (revision 116997) @@ -0,0 +1,7 @@ +char wrkstr_un[270]; +extern void +LoadUserAlph (char *s) +{ + s = &wrkstr_un[0]; + __builtin_strcpy (s, ""); +}; --- gcc/testsuite/gcc.c-torture/compile/memcpy-1.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/memcpy-1.c (revision 116997) @@ -0,0 +1,9 @@ +static const char OggFLAC__MAPPING_VERSION_MAJOR = 1; +void f(void) +{ + char synthetic_first_packet_body[10]; + char *b = &synthetic_first_packet_body[4]; + __builtin_memcpy (b, &OggFLAC__MAPPING_VERSION_MAJOR, (1u)); +} + + --- gcc/testsuite/gcc.c-torture/compile/memcpy-2.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/memcpy-2.c (revision 116997) @@ -0,0 +1,10 @@ +static const char OggFLAC__MAPPING_VERSION_MAJOR = 1; +void f(void) +{ + char synthetic_first_packet_body[10]; + char *b = synthetic_first_packet_body; + b+=4u; + __builtin_memcpy (b, &OggFLAC__MAPPING_VERSION_MAJOR, (1u)); +} + +