re PR debug/37287 (ICE (segfault) with new debugging patch)
authorJakub Jelinek <jakub@redhat.com>
Sun, 31 Aug 2008 11:23:04 +0000 (13:23 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 31 Aug 2008 11:23:04 +0000 (13:23 +0200)
PR debug/37287
* dwarf2out.c (gen_namespace_die): For DECL_EXTERNAL modules don't
add source coords.

* gfortran.dg/pr37287-1.f90: New test.
* gfortran.dg/pr37287-2.F90: New test.

From-SVN: r139826

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr37287-1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr37287-2.F90 [new file with mode: 0644]

index f78b20822541e0ce71a015892ddf9ca78375ed72..11c05928aceba6c0b114266e716a992d9b30d86b 100644 (file)
@@ -1,5 +1,9 @@
 2008-08-31  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/37287
+       * dwarf2out.c (gen_namespace_die): For DECL_EXTERNAL modules don't
+       add source coords.
+
        * dwarf2out.c (native_encode_initializer): Subtract min_index for
        non-range array index.  Handle VIEW_CONVERT_EXPR and NON_LVALUE_EXPR.
 
index 6a8d34c545597d3a4b20ece3326f896f5f6bdbc3..3e1bd5a60f06f6214eefcbbff7c28b9cdd8490f7 100644 (file)
@@ -15036,11 +15036,15 @@ gen_namespace_die (tree decl)
      they are an alias of.  */
   if (DECL_ABSTRACT_ORIGIN (decl) == NULL)
     {
-      /* Output a real namespace.  */
+      /* Output a real namespace or module.  */
       dw_die_ref namespace_die
        = new_die (is_fortran () ? DW_TAG_module : DW_TAG_namespace,
                   context_die, decl);
-      add_name_and_src_coords_attributes (namespace_die, decl);
+      /* For Fortran modules defined in different CU don't add src coords.  */
+      if (namespace_die->die_tag == DW_TAG_module && DECL_EXTERNAL (decl))
+       add_name_attribute (namespace_die, dwarf2_name (decl, 0));
+      else
+       add_name_and_src_coords_attributes (namespace_die, decl);
       if (DECL_EXTERNAL (decl))
        add_AT_flag (namespace_die, DW_AT_declaration, 1);
       equate_decl_number_to_die (decl, namespace_die);
index 647714a88b36251d280fcf162b332478c4d7dcfa..7e855c6ea24a554cb66173f18d62f711d5ebbedc 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/37287
+       * gfortran.dg/pr37287-1.f90: New test.
+       * gfortran.dg/pr37287-2.F90: New test.
+
 2008-08-31  Daniel Kraft  <d@domob.eu>
 
        * gfortran.dg/typebound_generic_1.f03: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr37287-1.f90 b/gcc/testsuite/gfortran.dg/pr37287-1.f90
new file mode 100644 (file)
index 0000000..629966f
--- /dev/null
@@ -0,0 +1,16 @@
+! PR debug/37287
+! { dg-do link }
+! { dg-options "-g -DPR37287_1" }
+! { dg-additional-sources pr37287-2.F90 }
+module pr37287_1
+  use iso_c_binding, only : c_ptr, c_associated, c_null_ptr
+  implicit none
+contains
+  subroutine set_null(ptr)
+      type(c_ptr), intent(out) :: ptr
+      ptr = c_null_ptr
+  end subroutine set_null
+end module pr37287_1
+end
+! { dg-final { cleanup-modules "pr37287_1" } }
+! { dg-final { cleanup-modules "pr37287_2" } }
diff --git a/gcc/testsuite/gfortran.dg/pr37287-2.F90 b/gcc/testsuite/gfortran.dg/pr37287-2.F90
new file mode 100644 (file)
index 0000000..330ab42
--- /dev/null
@@ -0,0 +1,10 @@
+! PR debug/37287
+! { dg-do compile }
+! { dg-options "-g" }
+module pr37287_2
+#ifdef PR37287_1
+  use pr37287_1
+#endif
+  implicit none
+end module pr37287_2
+! { dg-final { cleanup-modules "pr37287_2" } }