diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-05-09 18:17:33 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-05-09 18:17:33 +0000 |
commit | 3760428fe7d598ecb20f6439eb0da84fbcea3830 (patch) | |
tree | 3e9d50c5b8a7ede2cd680c832a69dd5133f46e01 /gcc/fold-const.c | |
parent | 8af5341f047f26c12d43b721995426f3f177f245 (diff) | |
download | gcc-3760428fe7d598ecb20f6439eb0da84fbcea3830.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159205 138bc75d-0d04-0410-961f-82ee72b054a4
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 ffd9d30ef2e..17a753692d5 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. */ |