re PR debug/51410 (duplicate variable DIE)
authorJakub Jelinek <jakub@redhat.com>
Mon, 5 Dec 2011 20:51:07 +0000 (21:51 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 5 Dec 2011 20:51:07 +0000 (21:51 +0100)
PR debug/51410
* c-decl.c (pop_scope): Don't add DECL_EXTERNAL decls
for debug info if scope is file_scope.

* gcc.dg/debug/dwarf2/pr51410.c: New test.

From-SVN: r182027

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/dwarf2/pr51410.c [new file with mode: 0644]

index 9767de4a63874a7d9a04ea2bc8c3ddbc91bad66c..52c1de56aefaecaa5faa61b6d8ca2f3c4b2acdc0 100644 (file)
@@ -1,5 +1,9 @@
 2011-12-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/51410
+       * c-decl.c (pop_scope): Don't add DECL_EXTERNAL decls
+       for debug info if scope is file_scope.
+
        PR c/51339
        * c-decl.c (c_finish_incomplete_decl, finish_decl): Call
        relayout_decl instead of layout_decl.
index 4338fdfc74633b555f64ec7f6f3f5d91006fbe85..1cdbf2fe6a8afa702dcacb4c74db7d0fe3c37606 100644 (file)
@@ -1196,7 +1196,7 @@ pop_scope (void)
              DECL_CHAIN (p) = BLOCK_VARS (block);
              BLOCK_VARS (block) = p;
            }
-         else if (VAR_OR_FUNCTION_DECL_P (p))
+         else if (VAR_OR_FUNCTION_DECL_P (p) && scope != file_scope)
            {
              /* For block local externs add a special
                 DECL_EXTERNAL decl for debug info generation.  */
index 73cef0b4c4e262000e982f8c4bdd78bdd76a11bb..654a56ea8068dac36832ca9ccbb79885acfe61f8 100644 (file)
@@ -1,5 +1,8 @@
 2011-12-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/51410
+       * gcc.dg/debug/dwarf2/pr51410.c: New test.
+
        PR c/51339
        * gcc.dg/gomp/pr51339.c: New test.
 
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/pr51410.c b/gcc/testsuite/gcc.dg/debug/dwarf2/pr51410.c
new file mode 100644 (file)
index 0000000..957c152
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR debug/51410 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -gdwarf-2 -dA -fno-merge-debug-strings" } */
+
+int x;
+
+int
+foo (void)
+{
+  return x;
+}
+
+/* { dg-final { scan-assembler-times "\\(DIE\[^\\r\\n\]*DW_TAG_variable\\)" 1 } } */