Commit 9166988f by Jakub Jelinek Committed by Jakub Jelinek

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
parent 0e0d82a7
2011-05-23 Jakub Jelinek <jakub@redhat.com> 2011-05-23 Jakub Jelinek <jakub@redhat.com>
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).
PR c/49120 PR c/49120
* c-decl.c (start_decl): Convert expr to void_type_node. * c-decl.c (start_decl): Convert expr to void_type_node.
......
...@@ -2957,7 +2957,8 @@ optabs.o : optabs.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ ...@@ -2957,7 +2957,8 @@ optabs.o : optabs.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
dbxout.o : dbxout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ dbxout.o : dbxout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) $(FLAGS_H) $(REGS_H) debug.h $(TM_P_H) $(TARGET_H) $(FUNCTION_H) \ $(RTL_H) $(FLAGS_H) $(REGS_H) debug.h $(TM_P_H) $(TARGET_H) $(FUNCTION_H) \
langhooks.h insn-config.h reload.h $(GSTAB_H) xcoffout.h output.h dbxout.h \ langhooks.h insn-config.h reload.h $(GSTAB_H) xcoffout.h output.h dbxout.h \
toplev.h $(DIAGNOSTIC_CORE_H) $(GGC_H) $(OBSTACK_H) $(EXPR_H) gt-dbxout.h toplev.h $(DIAGNOSTIC_CORE_H) $(GGC_H) $(OBSTACK_H) $(EXPR_H) $(CGRAPH_H) \
gt-dbxout.h
debug.o : debug.c debug.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) debug.o : debug.c debug.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H)
sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) debug.h \ sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) debug.h \
$(TREE_H) $(GGC_H) $(RTL_H) $(REGS_H) $(FLAGS_H) insn-config.h \ $(TREE_H) $(GGC_H) $(RTL_H) $(REGS_H) $(FLAGS_H) insn-config.h \
......
...@@ -91,6 +91,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -91,6 +91,7 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks.h" #include "langhooks.h"
#include "obstack.h" #include "obstack.h"
#include "expr.h" #include "expr.h"
#include "cgraph.h"
#ifdef XCOFF_DEBUGGING_INFO #ifdef XCOFF_DEBUGGING_INFO
#include "xcoffout.h" #include "xcoffout.h"
...@@ -2470,6 +2471,20 @@ dbxout_expand_expr (tree expr) ...@@ -2470,6 +2471,20 @@ dbxout_expand_expr (tree expr)
disable debug info for these variables. */ disable debug info for these variables. */
if (!targetm.have_tls && DECL_THREAD_LOCAL_P (expr)) if (!targetm.have_tls && DECL_THREAD_LOCAL_P (expr))
return NULL; 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 */ /* FALLTHRU */
case PARM_DECL: case PARM_DECL:
......
2011-05-23 Jakub Jelinek <jakub@redhat.com> 2011-05-23 Jakub Jelinek <jakub@redhat.com>
PR debug/49032
* gcc.dg/debug/pr49032.c: New test.
PR c/49120 PR c/49120
* gcc.dg/pr49120.c: New test. * gcc.dg/pr49120.c: New test.
......
/* PR debug/49032 */
/* { dg-do link } */
static int s = 42;
int
main ()
{
int *l[18] = { &s, &s, &s, &s, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return 0;
}
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