From: Roger Sayle Date: Sat, 15 May 2004 18:17:20 +0000 (+0000) Subject: builtins.c (simplify_builtin_strcpy): Avoid use of chainon... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e2bb53e59a21c042db3e0b605752e683d62618cc;p=gcc.git builtins.c (simplify_builtin_strcpy): Avoid use of chainon... * builtins.c (simplify_builtin_strcpy): Avoid use of chainon, so that simplify_builtin doesn't destructively modify its argument. From-SVN: r81893 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1a23cf1b356..2b1ef2c483a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-05-15 Roger Sayle + + * builtins.c (simplify_builtin_strcpy): Avoid use of chainon, so + that simplify_builtin doesn't destructively modify its argument. + 2004-05-15 Richard Earnshaw * arm/lib1funcs.asm (_lshrdi3, _ashrdi3, _ashldi3): Add ASM diff --git a/gcc/builtins.c b/gcc/builtins.c index b0375c377aa..7643b2dd383 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8298,7 +8298,7 @@ simplify_builtin_strpbrk (tree arglist) tree simplify_builtin_strcpy (tree arglist, tree len) { - tree fn; + tree fn, src, dst; if (!validate_arglist (arglist, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) return 0; @@ -8307,17 +8307,20 @@ simplify_builtin_strcpy (tree arglist, tree len) if (!fn) return 0; + src = TREE_VALUE (TREE_CHAIN (arglist)); + dst = TREE_VALUE (arglist); + if (!len) { - len = c_strlen (TREE_VALUE (TREE_CHAIN (arglist)), 1); - if (!len) - return 0; - if (TREE_SIDE_EFFECTS (len)) + len = c_strlen (src, 1); + if (!len || TREE_SIDE_EFFECTS (len)) return 0; } len = size_binop (PLUS_EXPR, len, ssize_int (1)); - chainon (arglist, build_tree_list (NULL_TREE, len)); + arglist = build_tree_list (NULL_TREE, len); + arglist = tree_cons (NULL_TREE, src, arglist); + arglist = tree_cons (NULL_TREE, dst, arglist); return build_function_call_expr (fn, arglist); }