OSDN Git Service

PR middle-end/18951
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2004 18:04:56 +0000 (18:04 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2004 18:04:56 +0000 (18:04 +0000)
* builtins.c (expand_builtin_mathfn, expand_builtin_mathfn_2,
expand_builtin_mathfn_3): Avoid using arguments passed to
save_expr after that call.

* gcc.c-torture/execute/20041213-1.c: New test.

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

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20041213-1.c [new file with mode: 0644]

index fc0e9b6..4368aea 100644 (file)
@@ -1,5 +1,10 @@
 2004-12-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/18951
+       * builtins.c (expand_builtin_mathfn, expand_builtin_mathfn_2,
+       expand_builtin_mathfn_3): Avoid using arguments passed to
+       save_expr after that call.
+
        * fold-const.c (fold_single_bit_test): If flag_syntax_only, pretend
        LOAD_EXTEND_OP is not defined.
        (fold): Likewise.  If flag_syntax_only, don't depend on BITS_PER_WORD.
index dfad35c..a6a80cf 100644 (file)
@@ -1771,6 +1771,7 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
       narg = builtin_save_expr (arg);
       if (narg != arg)
        {
+         arg = narg;
          arglist = build_tree_list (NULL_TREE, arg);
          exp = build_function_call_expr (fndecl, arglist);
        }
@@ -1910,6 +1911,7 @@ expand_builtin_mathfn_2 (tree exp, rtx target, rtx subtarget)
   narg = builtin_save_expr (arg1);
   if (narg != arg1)
     {
+      arg1 = narg;
       temp = build_tree_list (NULL_TREE, narg);
       stable = false;
     }
@@ -1919,6 +1921,7 @@ expand_builtin_mathfn_2 (tree exp, rtx target, rtx subtarget)
   narg = builtin_save_expr (arg0);
   if (narg != arg0)
     {
+      arg0 = narg;
       arglist = tree_cons (NULL_TREE, narg, temp);
       stable = false;
     }
@@ -2029,6 +2032,7 @@ expand_builtin_mathfn_3 (tree exp, rtx target, rtx subtarget)
       narg = save_expr (arg);
       if (narg != arg)
        {
+         arg = narg;
          arglist = build_tree_list (NULL_TREE, arg);
          exp = build_function_call_expr (fndecl, arglist);
        }
index 18420bf..720506d 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/18951
+       * gcc.c-torture/execute/20041213-1.c: New test.
+
 2004-12-14  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/18949
diff --git a/gcc/testsuite/gcc.c-torture/execute/20041213-1.c b/gcc/testsuite/gcc.c-torture/execute/20041213-1.c
new file mode 100644 (file)
index 0000000..07bdf68
--- /dev/null
@@ -0,0 +1,17 @@
+extern double sqrt (double);
+extern void abort (void);
+int once;
+
+double foo (void)
+{
+  if (once++)
+    abort ();
+  return 0.0 / 0.0;
+}
+
+double x;
+int main (void)
+{
+  x = sqrt (foo ());
+  return 0;
+}