diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3c9d149c0a3a..90c826f5a05a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-01-30 Richard Guenther + + PR middle-end/27657 + * dwarf2out.c (reference_to_unused): Query varpool if the + variable was output. + 2007-01-30 Richard Guenther PR middle-end/30313 diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 6cd343553949..2968d3b3547d 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -10045,8 +10045,14 @@ reference_to_unused (tree * tp, int * walk_subtrees, if (DECL_P (*tp) && ! TREE_PUBLIC (*tp) && ! TREE_USED (*tp) && ! TREE_ASM_WRITTEN (*tp)) return *tp; - else - return NULL_TREE; + else if (DECL_P (*tp) && TREE_CODE (*tp) != FUNCTION_DECL) + { + struct varpool_node *node = varpool_node (*tp); + if (!node->needed) + return *tp; + } + + return NULL_TREE; } /* Generate an RTL constant from a decl initializer INIT with decl type TYPE, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a8ad0c5d622d..be372cf48d8d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-01-30 Richard Guenther + + PR middle-end/27657 + * g++.dg/debug/pr27657.C: New testcase. + 2007-01-30 Richard Guenther PR middle-end/30313 diff --git a/gcc/testsuite/g++.dg/debug/pr27657.C b/gcc/testsuite/g++.dg/debug/pr27657.C new file mode 100644 index 000000000000..8351625bbf93 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr27657.C @@ -0,0 +1,9 @@ +/* { dg-do link } */ + +const char s[] = ""; +const char *const p = s; + +int main() +{ + return 0; +}