diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c7848ff20a4..970450b510f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-09-09 Richard Guenther + + PR tree-optimization/37433 + * tree-ssa-ccp.c (ccp_fold): Properly guard folding of + function calls. + 2008-09-09 Richard Guenther PR tree-optimization/37387 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c83bb25f402..1378257cee9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-09-09 Richard Guenther + + PR tree-optimization/37433 + * gcc.c-torture/compile/pr37433.c: New testcase. + 2008-09-09 Richard Guenther PR tree-optimization/37387 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37433.c b/gcc/testsuite/gcc.c-torture/compile/pr37433.c new file mode 100644 index 00000000000..0ba1179886c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr37433.c @@ -0,0 +1,11 @@ +int regex_subst(void) +{ + const void *subst = ""; + return (*(int (*)(int))subst) (0); +} + +int foobar (void) +{ + int x; + return (*(int (*)(void))&x) (); +} diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 8f700c47be2..22626a53840 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -1047,6 +1047,7 @@ ccp_fold (gimple stmt) fn = val->value; } if (TREE_CODE (fn) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL && DECL_BUILT_IN (TREE_OPERAND (fn, 0))) { tree *args = XALLOCAVEC (tree, gimple_call_num_args (stmt));