aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2014-01-17 15:42:58 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2014-01-17 15:42:58 +0100
commitf7d594d251bfc8adc3fff439fd67d343bd7f1981 (patch)
treeea2e9512771f68f8e5de0cc651b70f1871f1e0f8
parentdfc7b927f3bb5ed8cc8c9dbeba3405ff4e89f543 (diff)
downloadgcc-f7d594d251bfc8adc3fff439fd67d343bd7f1981.zip
gcc-f7d594d251bfc8adc3fff439fd67d343bd7f1981.tar.gz
gcc-f7d594d251bfc8adc3fff439fd67d343bd7f1981.tar.bz2
re PR fortran/59440 (ICE in force_decl_die, at dwarf2out.c:20111 with -g)
PR fortran/59440 * tree-nested.c (convert_nonlocal_reference_stmt, convert_local_reference_stmt): For NAMELIST_DECLs in gimple_bind_vars of GIMPLE_BIND stmts, adjust associated decls. * gfortran.dg/pr59440-1.f90: New test. * gfortran.dg/pr59440-2.f90: New test. * gfortran.dg/pr59440-3.f90: New test. From-SVN: r206711
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr59440-1.f9023
-rw-r--r--gcc/testsuite/gfortran.dg/pr59440-2.f9016
-rw-r--r--gcc/testsuite/gfortran.dg/pr59440-3.f9016
-rw-r--r--gcc/tree-nested.c49
6 files changed, 116 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0402a4d..d583762 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2014-01-17 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/59440
+ * tree-nested.c (convert_nonlocal_reference_stmt,
+ convert_local_reference_stmt): For NAMELIST_DECLs in gimple_bind_vars
+ of GIMPLE_BIND stmts, adjust associated decls.
+
2014-01-17 Richard Biener <rguenther@suse.de>
PR tree-optimization/46590
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cf0c3c8..1d7dcf7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2014-01-17 Jakub Jelinek <jakub@redhat.com>
+ PR fortran/59440
+ * gfortran.dg/pr59440-1.f90: New test.
+ * gfortran.dg/pr59440-2.f90: New test.
+ * gfortran.dg/pr59440-3.f90: New test.
+
PR testsuite/59064
* gcc.dg/vect/vect-ivdep-1.c: Replace two dg-bogus lines separately
testing for " version" and " alias" with one testing for
diff --git a/gcc/testsuite/gfortran.dg/pr59440-1.f90 b/gcc/testsuite/gfortran.dg/pr59440-1.f90
new file mode 100644
index 0000000..d874c6d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr59440-1.f90
@@ -0,0 +1,23 @@
+! PR fortran/59440
+! { dg-do compile }
+! { dg-options "-O2 -g" }
+
+module pr59440
+ implicit none
+ type t
+ integer :: grid = 0
+ end type t
+contains
+ subroutine read_nml (nnml, s)
+ integer, intent(in) :: nnml
+ type(t), intent(out) :: s
+ integer :: grid
+ namelist /N/ grid
+ call read_nml_type_2
+ s%grid = grid
+ contains
+ subroutine read_nml_type_2
+ read (nnml, nml=N)
+ end subroutine read_nml_type_2
+ end subroutine read_nml
+end module pr59440
diff --git a/gcc/testsuite/gfortran.dg/pr59440-2.f90 b/gcc/testsuite/gfortran.dg/pr59440-2.f90
new file mode 100644
index 0000000..a9f027c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr59440-2.f90
@@ -0,0 +1,16 @@
+! PR fortran/59440
+! { dg-do compile }
+! { dg-options "-O2 -g" }
+
+subroutine foo (nnml, outv)
+ integer, intent(in) :: nnml
+ integer, intent(out) :: outv
+ integer :: grid
+ namelist /N/ grid
+ read (nnml, nml=N)
+ call bar
+contains
+ subroutine bar
+ outv = grid
+ end subroutine bar
+end subroutine foo
diff --git a/gcc/testsuite/gfortran.dg/pr59440-3.f90 b/gcc/testsuite/gfortran.dg/pr59440-3.f90
new file mode 100644
index 0000000..70fe6a5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr59440-3.f90
@@ -0,0 +1,16 @@
+! PR fortran/59440
+! { dg-do compile }
+! { dg-options "-O2 -g" }
+
+subroutine foo (nnml, outv)
+ integer, intent(in) :: nnml
+ integer, intent(out) :: outv
+ integer :: grid
+ call bar
+ outv = grid
+contains
+ subroutine bar
+ namelist /N/ grid
+ read (nnml, nml=N)
+ end subroutine bar
+end subroutine foo
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 6d1b501..df6923f 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1331,6 +1331,25 @@ convert_nonlocal_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
if (!optimize && gimple_bind_block (stmt))
note_nonlocal_block_vlas (info, gimple_bind_block (stmt));
+ for (tree var = gimple_bind_vars (stmt); var; var = DECL_CHAIN (var))
+ if (TREE_CODE (var) == NAMELIST_DECL)
+ {
+ /* Adjust decls mentioned in NAMELIST_DECL. */
+ tree decls = NAMELIST_DECL_ASSOCIATED_DECL (var);
+ tree decl;
+ unsigned int i;
+
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (decls), i, decl)
+ {
+ if (TREE_CODE (decl) == VAR_DECL
+ && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
+ continue;
+ if (decl_function_context (decl) != info->context)
+ CONSTRUCTOR_ELT (decls, i)->value
+ = get_nonlocal_debug_decl (info, decl);
+ }
+ }
+
*handled_ops_p = false;
return NULL_TREE;
@@ -1787,6 +1806,36 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
*handled_ops_p = false;
return NULL_TREE;
+ case GIMPLE_BIND:
+ for (tree var = gimple_bind_vars (stmt); var; var = DECL_CHAIN (var))
+ if (TREE_CODE (var) == NAMELIST_DECL)
+ {
+ /* Adjust decls mentioned in NAMELIST_DECL. */
+ tree decls = NAMELIST_DECL_ASSOCIATED_DECL (var);
+ tree decl;
+ unsigned int i;
+
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (decls), i, decl)
+ {
+ if (TREE_CODE (decl) == VAR_DECL
+ && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
+ continue;
+ if (decl_function_context (decl) == info->context
+ && !use_pointer_in_frame (decl))
+ {
+ tree field = lookup_field_for_decl (info, decl, NO_INSERT);
+ if (field)
+ {
+ CONSTRUCTOR_ELT (decls, i)->value
+ = get_local_debug_decl (info, decl, field);
+ }
+ }
+ }
+ }
+
+ *handled_ops_p = false;
+ return NULL_TREE;
+
default:
/* For every other statement that we are not interested in
handling here, let the walker traverse the operands. */