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] DWARF: remove pessimistic DWARF version checks for imported entities


Hello,

A check in dwarf2out_imported_module_or_decl prevents valid strict
DWARF2 constructs such as DW_TAG_imported_declaration from being emitted
in dwarf2out_imported_module_or_decl_1.

The latter already protects the emission of newer DWARF tags with
appropriate checks, so the one in the former is redundant and
pessimistic.  This function is already called from places like
process_scope_var, which are not protected anyway.

This patch removes the check in dwarf2out_imported_module_or_decl so
that tags like DW_TAG_imported_declaration are emitted even in strict
DWARF2 mode.

Bootstrapped and regtested on x86_64-linux, no regression.  I also
checked that the new testcase fails on mainline.  Ok to commit?
Thank you in advance!

gcc/

	* dwarf2out.c (dwarf2out_imported_module_or_decl): Remove
	pessimistic DWARF version check.

gcc/testsuite/

	* gnat.dg/debug7.adb, gnat.dg/debug7.ads: New testcase.
---
 gcc/dwarf2out.c                  |  3 ---
 gcc/testsuite/gnat.dg/debug7.adb | 10 ++++++++++
 gcc/testsuite/gnat.dg/debug7.ads |  4 ++++
 3 files changed, 14 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gnat.dg/debug7.adb
 create mode 100644 gcc/testsuite/gnat.dg/debug7.ads

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 0fdab9a..7bc0378 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -24034,9 +24034,6 @@ dwarf2out_imported_module_or_decl (tree decl, tree name, tree context,
       && !should_emit_struct_debug (context, DINFO_USAGE_DIR_USE))
     return;
 
-  if (!(dwarf_version >= 3 || !dwarf_strict))
-    return;
-
   scope_die = get_context_die (context);
 
   if (child)
diff --git a/gcc/testsuite/gnat.dg/debug7.adb b/gcc/testsuite/gnat.dg/debug7.adb
new file mode 100644
index 0000000..98230ba
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug7.adb
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+-- { dg-options "-cargs -g -gdwarf-2 -gstrict-dwarf -dA" }
+-- { dg-final { scan-assembler "DW_TAG_imported_decl" } }
+
+package body Debug7 is
+   function Next (I : Integer) return Integer is
+   begin
+      return I + 1;
+   end Next;
+end Debug7;
diff --git a/gcc/testsuite/gnat.dg/debug7.ads b/gcc/testsuite/gnat.dg/debug7.ads
new file mode 100644
index 0000000..047d4a6
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug7.ads
@@ -0,0 +1,4 @@
+package Debug7 is
+   function Next (I : Integer) return Integer;
+   function Renamed_Next (I : Integer) return Integer renames Next;
+end Debug7;
-- 
2.9.3


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