DWARF: move pessimistic DWARF version checks for imported entities
authorPierre-Marie de Rodat <derodat@adacore.com>
Wed, 5 Oct 2016 07:53:37 +0000 (07:53 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Wed, 5 Oct 2016 07:53:37 +0000 (07:53 +0000)
A check in dwarf2out_imported_module_or_decl prevents
DW_TAG_imported_module from being emitted as it was introduced in the
DWARFv3 standard. However, this also prevents valid strict DWARFv2
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 moves the check in dwarf2out_imported_module_or_decl so that
in strict DWARFv2 mode, tags like DW_TAG_imported_declaration are
emitted while DW_TAG_imported_module are not.

gcc/

* dwarf2out.c (dwarf2out_imported_module_or_decl): Move DWARF
version check to protect only DW_TAG_imported_module generation.

gcc/testsuite/

* gnat.dg/debug7.adb, gnat.dg/debug7.ads: New testcase.

From-SVN: r240772

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/debug7.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/debug7.ads [new file with mode: 0644]

index a65f491b3ee8596ebd3ae5136099719eccd067eb..34efb7c54282adca9bc12eefe3e156aa87cd089d 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-05  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * dwarf2out.c (dwarf2out_imported_module_or_decl): Move DWARF
+       version check to protect only DW_TAG_imported_module generation.
+
 2016-10-05  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/55152
index 7b5acda5f7c7b9e60fba0b7bd0169f5167391f14..23eaebcc370d98b5a018fcc5f8263dfaebde9ec6 100644 (file)
@@ -24045,13 +24045,15 @@ 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)
     {
+      /* DW_TAG_imported_module was introduced in the DWARFv3 specification, so
+        there is nothing we can do, here.  */
+      if (dwarf_version < 3 && dwarf_strict)
+       return;
+
       gcc_assert (scope_die->die_child);
       gcc_assert (scope_die->die_child->die_tag == DW_TAG_imported_module);
       gcc_assert (TREE_CODE (decl) != NAMESPACE_DECL);
index e77ed889553ad214beb28f43474fb81a7e63720c..0280ff0e0a55c07ed75b7a0ea1642e73fdfef65e 100644 (file)
@@ -1,3 +1,7 @@
+2016-10-05  Pierre-Marie de Rodat  <derodat@adacore.com>
+
+       * gnat.dg/debug7.adb, gnat.dg/debug7.ads: New testcase.
+
 2016-10-05  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/55152
diff --git a/gcc/testsuite/gnat.dg/debug7.adb b/gcc/testsuite/gnat.dg/debug7.adb
new file mode 100644 (file)
index 0000000..cdaf089
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+-- { dg-options "-cargs -g -gdwarf-2 -gstrict-dwarf -dA -margs" }
+-- { 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 (file)
index 0000000..047d4a6
--- /dev/null
@@ -0,0 +1,4 @@
+package Debug7 is
+   function Next (I : Integer) return Integer;
+   function Renamed_Next (I : Integer) return Integer renames Next;
+end Debug7;