aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2009-04-10 16:06:43 +0000
committerPaolo Bonzini <bonzini@gcc.gnu.org>2009-04-10 16:06:43 +0000
commit4d35e75cf9b4acaca40316a42de29ab3858b5c91 (patch)
tree38ec6987cc46a8bcdf13c9c03745d832bd8c8eb5
parentb0d3b11d8c1b75fd46510845e2b352e8a22e1e9d (diff)
downloadgcc-4d35e75cf9b4acaca40316a42de29ab3858b5c91.zip
gcc-4d35e75cf9b4acaca40316a42de29ab3858b5c91.tar.gz
gcc-4d35e75cf9b4acaca40316a42de29ab3858b5c91.tar.bz2
re PR middle-end/39701 (Revision 145846 caused many test failures)
2009-04-10 Paolo Bonzini <bonzini@gnu.org> PR middle-end/39701 * fold-const.c (tree_single_nonzero_warnv_p): Pass non-static variables as non-NULL even with -fdelete-null-pointer-checks. From-SVN: r145927
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c8
2 files changed, 12 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 62a1c43..a77df07 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2009-04-10 Paolo Bonzini <bonzini@gnu.org>
+
+ PR middle-end/39701
+ * fold-const.c (tree_single_nonzero_warnv_p): Pass non-static
+ variables as non-NULL even with -fdelete-null-pointer-checks.
+
2009-04-10 H.J. Lu <hongjiu.lu@intel.com>
* config/rs6000/darwin-vecsave.asm: Remove extra "*/".
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 821e581..dd2f62d 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -15017,8 +15017,12 @@ tree_single_nonzero_warnv_p (tree t, bool *strict_overflow_p)
if (!base)
return false;
- /* Weak declarations may link to NULL. */
- if (DECL_P (base) && flag_delete_null_pointer_checks)
+ /* Weak declarations may link to NULL. Other things may also be NULL
+ so protect with -fdelete-null-pointer-checks; but not variables
+ allocated on the stack. */
+ if (DECL_P (base)
+ && (flag_delete_null_pointer_checks
+ || (TREE_CODE (base) == VAR_DECL && !TREE_STATIC (base))))
return !VAR_OR_FUNCTION_DECL_P (base) || !DECL_WEAK (base);
/* Constants are never weak. */