re PR middle-end/18951 (Invalid code generated by expand_errno_check)

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.

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

From-SVN: r92151
This commit is contained in:
Jakub Jelinek 2004-12-14 19:04:56 +01:00 committed by Jakub Jelinek
parent 2a1a3cd51f
commit 29bfcb6de7
4 changed files with 31 additions and 0 deletions

View File

@ -1,5 +1,10 @@
2004-12-14 Jakub Jelinek <jakub@redhat.com> 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 * fold-const.c (fold_single_bit_test): If flag_syntax_only, pretend
LOAD_EXTEND_OP is not defined. LOAD_EXTEND_OP is not defined.
(fold): Likewise. If flag_syntax_only, don't depend on BITS_PER_WORD. (fold): Likewise. If flag_syntax_only, don't depend on BITS_PER_WORD.

View File

@ -1771,6 +1771,7 @@ expand_builtin_mathfn (tree exp, rtx target, rtx subtarget)
narg = builtin_save_expr (arg); narg = builtin_save_expr (arg);
if (narg != arg) if (narg != arg)
{ {
arg = narg;
arglist = build_tree_list (NULL_TREE, arg); arglist = build_tree_list (NULL_TREE, arg);
exp = build_function_call_expr (fndecl, arglist); 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); narg = builtin_save_expr (arg1);
if (narg != arg1) if (narg != arg1)
{ {
arg1 = narg;
temp = build_tree_list (NULL_TREE, narg); temp = build_tree_list (NULL_TREE, narg);
stable = false; stable = false;
} }
@ -1919,6 +1921,7 @@ expand_builtin_mathfn_2 (tree exp, rtx target, rtx subtarget)
narg = builtin_save_expr (arg0); narg = builtin_save_expr (arg0);
if (narg != arg0) if (narg != arg0)
{ {
arg0 = narg;
arglist = tree_cons (NULL_TREE, narg, temp); arglist = tree_cons (NULL_TREE, narg, temp);
stable = false; stable = false;
} }
@ -2029,6 +2032,7 @@ expand_builtin_mathfn_3 (tree exp, rtx target, rtx subtarget)
narg = save_expr (arg); narg = save_expr (arg);
if (narg != arg) if (narg != arg)
{ {
arg = narg;
arglist = build_tree_list (NULL_TREE, arg); arglist = build_tree_list (NULL_TREE, arg);
exp = build_function_call_expr (fndecl, arglist); exp = build_function_call_expr (fndecl, arglist);
} }

View 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> 2004-12-14 Nathan Sidwell <nathan@codesourcery.com>
PR c++/18949 PR c++/18949

View File

@ -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;
}