2007-01-30 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Jan 2007 10:23:01 +0000 (10:23 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Jan 2007 10:23:01 +0000 (10:23 +0000)
PR middle-end/27657
* dwarf2out.c (reference_to_unused): Query varpool if the
variable was output.

* g++.dg/debug/pr27657.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121335 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/pr27657.C [new file with mode: 0644]

index 3c9d149..90c826f 100644 (file)
@@ -1,5 +1,11 @@
 2007-01-30  Richard Guenther  <rguenther@suse.de>
 
+       PR middle-end/27657
+       * dwarf2out.c (reference_to_unused): Query varpool if the
+       variable was output.
+
+2007-01-30  Richard Guenther  <rguenther@suse.de>
+
        PR middle-end/30313
        * passes.c (execute_one_pass): Reset in_gimple_form to not
        confuse non-unit-at-a-time mode.
index 6cd3435..2968d3b 100644 (file)
@@ -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,
index a8ad0c5..be372cf 100644 (file)
@@ -1,5 +1,10 @@
 2007-01-30  Richard Guenther  <rguenther@suse.de>
 
+       PR middle-end/27657
+       * g++.dg/debug/pr27657.C: New testcase.
+
+2007-01-30  Richard Guenther  <rguenther@suse.de>
+
        PR middle-end/30313
        * gcc.dg/torture/pr30313.c: New testcase.
 
diff --git a/gcc/testsuite/g++.dg/debug/pr27657.C b/gcc/testsuite/g++.dg/debug/pr27657.C
new file mode 100644 (file)
index 0000000..8351625
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do link } */
+
+const char s[] = "";
+const char *const p = s;
+
+int main()
+{
+  return 0;
+}