This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't emit unnecessary DIEs for file scope vars (PR debug/51410)


Hi!

The VAR_DECL in this testcase is pushed to both external_scope
and file_scope, which unfortunately triggers the creation of the local
extern I've added for PR39563.  That was only intended for function scope,
for DWARF file_scope and external_scope are the same thing.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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.

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

--- gcc/c-decl.c.jj	2011-12-05 16:39:46.000000000 +0100
+++ gcc/c-decl.c	2011-12-05 18:02:13.274191017 +0100
@@ -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.  */
--- gcc/testsuite/gcc.dg/debug/dwarf2/pr51410.c.jj	2011-12-05 18:07:27.254337634 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/pr51410.c	2011-12-05 18:07:22.350366223 +0100
@@ -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 } } */

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]