From da69cc9160391a75d646caf33d0c6a4074277646 Mon Sep 17 00:00:00 2001 From: George Helffrich Date: Sat, 26 Apr 2008 09:46:01 +0000 Subject: [PATCH] re PR fortran/35892 (gfortran lost memory blocks) 2008-04-26 George Helffrich 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 | 7 ++++ gcc/fortran/trans-common.c | 8 +++- gcc/testsuite/ChangeLog | 8 ++++ .../gfortran.dg/debug/pr35154-dwarf2.f | 37 +++++++++++++++++++ .../gfortran.dg/debug/pr35154-stabs.f | 35 ++++++++++++++++++ 5 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/debug/pr35154-dwarf2.f create mode 100644 gcc/testsuite/gfortran.dg/debug/pr35154-stabs.f diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ee39ef18c3c..dbe52c3ff1a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2008-04-26 George Helffrich + + 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 * trans-decl.c (trans_function_start): Update. diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c index c6a386e0120..5c91bf57946 100644 --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -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), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8f91bfd5752..3f4c66b5f2f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2008-04-26 George Helffrich + + 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 * 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 index 00000000000..0203d134a62 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/debug/pr35154-dwarf2.f @@ -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 index 00000000000..7294771bd3e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/debug/pr35154-stabs.f @@ -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" } } -- 2.30.2