diff options
author | Richard Guenther <rguenther@suse.de> | 2010-05-09 18:17:33 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-05-09 18:17:33 +0000 |
commit | 3d7a712a1e3b2e67b5261e8e4b34f3b701f49a70 (patch) | |
tree | 3e9d50c5b8a7ede2cd680c832a69dd5133f46e01 /gcc/fold-const.c | |
parent | 492fc0eec511c06f6f159b7d88bc7a8212ce5c23 (diff) | |
download | gcc-3d7a712a1e3b2e67b5261e8e4b34f3b701f49a70.zip gcc-3d7a712a1e3b2e67b5261e8e4b34f3b701f49a70.tar.gz gcc-3d7a712a1e3b2e67b5261e8e4b34f3b701f49a70.tar.bz2 |
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
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ffd9d30..17a7536 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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. */ |