re PR c/44024 (missed optimization)

2010-05-09  Richard Guenther  <rguenther@suse.de>

	PR middle-end/44024
	* fold-const.c (tree_single_nonzero_warnv_p): Properly
	handle &FUNCTION_DECL.

	* gcc.dg/pr44024.c: New testcase.

From-SVN: r159205
This commit is contained in:
Richard Guenther 2010-05-09 18:17:33 +00:00 committed by Richard Biener
parent 492fc0eec5
commit 3d7a712a1e
4 changed files with 31 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2010-05-09 Richard Guenther <rguenther@suse.de>
PR middle-end/44024
* fold-const.c (tree_single_nonzero_warnv_p): Properly
handle &FUNCTION_DECL.
2010-05-09 Joseph Myers <joseph@codesourcery.com>
PR c/4784

View File

@ -14917,7 +14917,9 @@ tree_single_nonzero_warnv_p (tree t, bool *strict_overflow_p)
case ADDR_EXPR:
{
tree base = get_base_address (TREE_OPERAND (t, 0));
tree base = TREE_OPERAND (t, 0);
if (!DECL_P (base))
base = get_base_address (base);
if (!base)
return false;
@ -14927,7 +14929,9 @@ tree_single_nonzero_warnv_p (tree t, bool *strict_overflow_p)
allocated on the stack. */
if (DECL_P (base)
&& (flag_delete_null_pointer_checks
|| (TREE_CODE (base) == VAR_DECL && !TREE_STATIC (base))))
|| (DECL_CONTEXT (base)
&& TREE_CODE (DECL_CONTEXT (base)) == FUNCTION_DECL
&& auto_var_in_fn_p (base, DECL_CONTEXT (base)))))
return !VAR_OR_FUNCTION_DECL_P (base) || !DECL_WEAK (base);
/* Constants are never weak. */

View File

@ -1,3 +1,8 @@
2010-05-09 Richard Guenther <rguenther@suse.de>
PR middle-end/44024
* gcc.dg/pr44024.c: New testcase.
2010-05-09 Joseph Myers <joseph@codesourcery.com>
PR c/4784

View File

@ -0,0 +1,14 @@
/* { dg-do link } */
/* { dg-options "-fdelete-null-pointer-checks -fdump-tree-original" } */
void foo();
int main()
{
if (foo == (void *)0)
link_error ();
return 0;
}
/* { dg-final { scan-tree-dump-not "foo" "original" } } */
/* { dg-final { cleanup-tree-dump "original" } } */