Commit 3d7a712a by Richard Guenther Committed by Richard Biener

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
parent 492fc0ee
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
......
......@@ -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. */
......
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
......
/* { 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment