re PR fortran/35892 (gfortran lost memory blocks)
authorGeorge Helffrich <george@gcc.gnu.org>
Sat, 26 Apr 2008 09:46:01 +0000 (09:46 +0000)
committerGeorge Helffrich <george@gcc.gnu.org>
Sat, 26 Apr 2008 09:46:01 +0000 (09:46 +0000)
2008-04-26  George Helffrich <george@gcc.gnu.org>

PR fortran/35892
PR fortran/35154
* fortran/trans-common.c (create_common):  Add decl to function
chain (if inside one) to preserve identifier scope in debug output.

        * testsuite/gfortran.dg/debug/pr35154-stabs.f:  New test case for
        .stabs functionality.
        * testsuite/gfortran.dg/debug/pr35154-dwarf2.f:  New test case for
        DWARF functionality.

From-SVN: r134696

gcc/fortran/ChangeLog
gcc/fortran/trans-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/debug/pr35154-dwarf2.f [new file with mode: 0644]
gcc/testsuite/gfortran.dg/debug/pr35154-stabs.f [new file with mode: 0644]

index ee39ef18c3c7382566f05b10ca9d6d235a1f9977..dbe52c3ff1a854f94e7923c5d11fa7cddc97ba61 100644 (file)
@@ -1,3 +1,10 @@
+2008-04-26  George Helffrich <george@gcc.gnu.org>
+
+       PR fortran/35892
+       PR fortran/35154
+       * trans-common.c (create_common):  Add decl to function
+       chain (if inside one) to preserve identifier scope in debug output.
+
 2008-04-25  Jan Hubicka  <jh@suse.cz>
 
        * trans-decl.c (trans_function_start): Update.
index c6a386e01208360361cb53e75d69f95b987f82e2..5c91bf57946deade368b3f9297e074841790a4c7 100644 (file)
@@ -685,10 +685,14 @@ create_common (gfc_common_head *com, segment_info *head, bool saw_equiv)
       /* This is a fake variable just for debugging purposes.  */
       TREE_ASM_WRITTEN (var_decl) = 1;
       
-      if (com)
+      /* To preserve identifier names in COMMON, chain to procedure
+         scope unless at top level in a module definition.  */
+      if (com
+          && s->sym->ns->proc_name
+          && s->sym->ns->proc_name->attr.flavor == FL_MODULE)
        var_decl = pushdecl_top_level (var_decl);
       else
-       gfc_add_decl_to_function (var_decl);    
+       gfc_add_decl_to_function (var_decl);
 
       SET_DECL_VALUE_EXPR (var_decl,
                           fold_build3 (COMPONENT_REF, TREE_TYPE (s->field),
index 8f91bfd57526a6ab13f6bb2b3170b9b9b1bd504a..3f4c66b5f2fc66ae709d4880529a7ba4c5cac253 100644 (file)
@@ -1,3 +1,11 @@
+2008-04-26  George Helffrich  <george@gcc.gnu.org>
+
+       PRs fortran/PR35154, fortran/PR23057
+        * gfortran.dg/debug/pr35154-stabs.f:  New test case for
+        .stabs functionality.
+        * gfortran.dg/debug/pr35154-dwarf2.f:  New test case for
+        DWARF functionality.
+  
 2008-04-26  Richard Sandiford  <rsandifo@nildram.co.uk>
 
        * gcc.target/mips/gcc-have-sync-compare-and-swap-1.c: Expect
diff --git a/gcc/testsuite/gfortran.dg/debug/pr35154-dwarf2.f b/gcc/testsuite/gfortran.dg/debug/pr35154-dwarf2.f
new file mode 100644 (file)
index 0000000..0203d13
--- /dev/null
@@ -0,0 +1,37 @@
+C     Test program for common block debugging.  G. Helffrich 11 July 2004.
+C { dg-do compile }
+C { dg-skip-if "DWARF-2 only" { "*-*-*" } { "*" } { "-gdwarf-2" } }
+C { dg-options "-dA" }
+      common i,j
+      common /label/l,m
+      i = 1
+      j = 2
+      k = 3
+      l = 4
+      m = 5
+      call sub
+      end
+      subroutine sub
+      common /label/l,m
+      logical first
+      save n
+      data first /.true./
+      if (first) then
+         n = 0
+        first = .false.
+      endif
+      n = n + 1
+      l = l + 1
+      return
+      end
+
+C { dg-final { scan-assembler "(DIE.*DW_TAG_common_block)" } }
+C { dg-final { scan-assembler "DW_AT_name: \"__BLNK__\"" } }
+C { dg-final { scan-assembler "(DIE.*DW_TAG_member)" } }
+C { dg-final { scan-assembler "\"i.*\".*DW_AT_name" } }
+C { dg-final { scan-assembler "\"j.*\".*DW_AT_name" } }
+C { dg-final { scan-assembler "(DIE.*DW_TAG_common_block)" } }
+C { dg-final { scan-assembler "DW_AT_name: \"label\"" } }
+C { dg-final { scan-assembler "(DIE.*DW_TAG_member)" } }
+C { dg-final { scan-assembler "\"l.*\".*DW_AT_name" } }
+C { dg-final { scan-assembler "\"m.*\".*DW_AT_name" } }
diff --git a/gcc/testsuite/gfortran.dg/debug/pr35154-stabs.f b/gcc/testsuite/gfortran.dg/debug/pr35154-stabs.f
new file mode 100644 (file)
index 0000000..7294771
--- /dev/null
@@ -0,0 +1,35 @@
+C     Test program for common block debugging.  G. Helffrich 11 July 2004.
+C { dg-do compile }
+C { dg-skip-if "No stabs" { mmix-*-* *-*-netware* alpha*-*-* hppa*64*-*-* ia64-*-* *-*-sysv5* *-*-vxworks* } { "*" } { "" } }
+C { dg-skip-if "No stabs" {*-*-* } { "*" } { "-gstabs" } }
+      common i,j
+      common /label/l,m
+      i = 1
+      j = 2
+      k = 3
+      l = 4
+      m = 5
+      call sub
+      end
+      subroutine sub
+      common /label/l,m
+      logical first
+      save n
+      data first /.true./
+      if (first) then
+         n = 0
+        first = .false.
+      endif
+      n = n + 1
+      l = l + 1
+      return
+      end
+
+C { dg-final { scan-assembler ".stabs.*\"__BLNK__\",226" } }
+C { dg-final { scan-assembler ".stabs.*\"i:V.*\",.*,0" } }
+C { dg-final { scan-assembler ".stabs.*\"j:V.*\",.*,4" } }
+C { dg-final { scan-assembler ".stabs.*\"__BLNK__\",228" } }
+C { dg-final { scan-assembler ".stabs.*\"label_\",226" } }
+C { dg-final { scan-assembler ".stabs.*\"l:V.*\",.*,0" } }
+C { dg-final { scan-assembler ".stabs.*\"m:V.*\",.*,4" } }
+C { dg-final { scan-assembler ".stabs.*\"label_\",228" } }