aboutsummaryrefslogtreecommitdiff
path: root/gcc/dbxout.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2011-05-23 20:07:43 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2011-05-23 20:07:43 +0200
commit9166988f2635469e9e7a85e0473df7b0eee689ee (patch)
treef455a1ce76ac8044485fea91c9fb66093a4de7f3 /gcc/dbxout.c
parent0e0d82a784effdcfab26696cab66d03ed5f22300 (diff)
downloadgcc-9166988f2635469e9e7a85e0473df7b0eee689ee.zip
gcc-9166988f2635469e9e7a85e0473df7b0eee689ee.tar.gz
gcc-9166988f2635469e9e7a85e0473df7b0eee689ee.tar.bz2
re PR debug/49032 (-gstabs generates reference to deleted static variable)
PR debug/49032 * dbxout.c: Include cgraph.h. (dbxout_expand_expr): If a VAR_DECL is TREE_STATIC, not written and without value expr, return NULL if no varpool node exists for it or if it is not needed. * Makefile.in (dbxout.o): Depend on $(CGRAPH_H). * gcc.dg/debug/pr49032.c: New test. From-SVN: r174083
Diffstat (limited to 'gcc/dbxout.c')
-rw-r--r--gcc/dbxout.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index 3190803..be43ed3 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -91,6 +91,7 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h"
#include "obstack.h"
#include "expr.h"
+#include "cgraph.h"
#ifdef XCOFF_DEBUGGING_INFO
#include "xcoffout.h"
@@ -2470,6 +2471,20 @@ dbxout_expand_expr (tree expr)
disable debug info for these variables. */
if (!targetm.have_tls && DECL_THREAD_LOCAL_P (expr))
return NULL;
+ if (TREE_STATIC (expr)
+ && !TREE_ASM_WRITTEN (expr)
+ && !DECL_HAS_VALUE_EXPR_P (expr)
+ && !TREE_PUBLIC (expr)
+ && DECL_RTL_SET_P (expr)
+ && MEM_P (DECL_RTL (expr)))
+ {
+ /* If this is a var that might not be actually output,
+ return NULL, otherwise stabs might reference an undefined
+ symbol. */
+ struct varpool_node *node = varpool_get_node (expr);
+ if (!node || !node->needed)
+ return NULL;
+ }
/* FALLTHRU */
case PARM_DECL: