re PR fortran/47797 (Debug: Odd first break point for subroutine breakp w/ allocatables)
authorTobias Burnus <burnus@net-b.de>
Sun, 20 Feb 2011 22:16:47 +0000 (23:16 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Sun, 20 Feb 2011 22:16:47 +0000 (23:16 +0100)
2011-02-20  Tobias Burnus  <burnus@net-b.de>

        PR fortran/47797
        * trans-decl.c (gfc_trans_deferred_vars): Use gfc_set_backend_locus
        and gfc_restore_backend_locus to have better debug locations.
        * trans-array.c (gfc_trans_deferred_array): Ditto.

From-SVN: r170347

gcc/fortran/ChangeLog
gcc/fortran/trans-array.c
gcc/fortran/trans-decl.c

index 3d98c0a348b1e539004fab56fd09dc1baebb5a93..951be24dc124d8efc9cfcff17ceda5f5d3017c7a 100644 (file)
@@ -1,3 +1,10 @@
+2011-02-20  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/47797
+       * trans-decl.c (gfc_trans_deferred_vars): Use gfc_set_backend_locus and
+       gfc_restore_backend_locus to have better debug locations.
+       * trans-array.c (gfc_trans_deferred_array): Ditto.
+
 2011-02-20  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/45077
index 83f0189de757b01febe9b01f533efe6d63371f7e..4e901f27680b45be5942d428de27197b89e40192 100644 (file)
@@ -7156,6 +7156,8 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
                 "allocatable attribute or derived type without allocatable "
                 "components.");
 
+  gfc_save_backend_locus (&loc);
+  gfc_set_backend_locus (&sym->declared_at);
   gfc_init_block (&init);
 
   gcc_assert (TREE_CODE (sym->backend_decl) == VAR_DECL
@@ -7172,11 +7174,10 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
   if (sym->attr.dummy || sym->attr.use_assoc || sym->attr.result)
     {
       gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
+      gfc_restore_backend_locus (&loc);
       return;
     }
 
-  gfc_save_backend_locus (&loc);
-  gfc_set_backend_locus (&sym->declared_at);
   descriptor = sym->backend_decl;
 
   /* Although static, derived types with default initializers and
@@ -7225,8 +7226,8 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
   if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save)
     gfc_conv_descriptor_data_set (&init, descriptor, null_pointer_node);
 
-  gfc_init_block (&cleanup);
   gfc_restore_backend_locus (&loc);
+  gfc_init_block (&cleanup);
 
   /* Allocatable arrays need to be freed when they go out of scope.
      The allocatable components of pointers must not be touched.  */
index 2315b231c81d79cccb967100081ae5565f7b89dd..616cca8f36808eb149ecb77afda70be8b9fed545 100644 (file)
@@ -3318,6 +3318,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
          if (proc_sym->ts.deferred)
            {
              tmp = NULL;
+             gfc_save_backend_locus (&loc);
+             gfc_set_backend_locus (&proc_sym->declared_at);
              gfc_start_block (&init);
              /* Zero the string length on entry.  */
              gfc_add_modify (&init, proc_sym->ts.u.cl->backend_decl,
@@ -3332,6 +3334,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
              gfc_add_modify (&init, tmp,
                              fold_convert (TREE_TYPE (se.expr),
                                            null_pointer_node));
+             gfc_restore_backend_locus (&loc);
 
              /* Pass back the string length on exit.  */
              tmp = proc_sym->ts.u.cl->passed_length;
@@ -3353,7 +3356,10 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
   /* Initialize the INTENT(OUT) derived type dummy arguments.  This
      should be done here so that the offsets and lbounds of arrays
      are available.  */
+  gfc_save_backend_locus (&loc);
+  gfc_set_backend_locus (&proc_sym->declared_at);
   init_intent_out_dt (proc_sym, block);
+  gfc_restore_backend_locus (&loc);
 
   for (sym = proc_sym->tlink; sym != proc_sym; sym = sym->tlink)
     {
@@ -3372,7 +3378,12 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
              else if (sym->attr.pointer || sym->attr.allocatable)
                {
                  if (TREE_STATIC (sym->backend_decl))
-                   gfc_trans_static_array_pointer (sym);
+                   {
+                     gfc_save_backend_locus (&loc);
+                     gfc_set_backend_locus (&sym->declared_at);
+                     gfc_trans_static_array_pointer (sym);
+                     gfc_restore_backend_locus (&loc);
+                   }
                  else
                    {
                      seen_trans_deferred_array = true;
@@ -3381,6 +3392,9 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
                }
              else
                {
+                 gfc_save_backend_locus (&loc);
+                 gfc_set_backend_locus (&sym->declared_at);
+
                  if (sym_has_alloc_comp)
                    {
                      seen_trans_deferred_array = true;
@@ -3398,8 +3412,6 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
                                            NULL_TREE);
                    }
 
-                 gfc_save_backend_locus (&loc);
-                 gfc_set_backend_locus (&sym->declared_at);
                  gfc_trans_auto_array_allocation (sym->backend_decl,
                                                   sym, block);
                  gfc_restore_backend_locus (&loc);
@@ -3451,6 +3463,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
              gfc_conv_expr (&se, e);
              gfc_free_expr (e);
 
+             gfc_save_backend_locus (&loc);
+             gfc_set_backend_locus (&sym->declared_at);
              gfc_start_block (&init);
 
              if (!sym->attr.dummy || sym->attr.intent == INTENT_OUT)
@@ -3477,6 +3491,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
                  else
                    gfc_add_modify (&init, sym->ts.u.cl->backend_decl, tmp);
 
+                 gfc_restore_backend_locus (&loc);
+
                  /* Pass the final character length back.  */
                  if (sym->attr.intent != INTENT_IN)
                    tmp = fold_build2_loc (input_location, MODIFY_EXPR,
@@ -3485,6 +3501,8 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
                  else
                    tmp = NULL_TREE;
                }
+             else
+               gfc_restore_backend_locus (&loc);
 
              /* Deallocate when leaving the scope. Nullifying is not
                 needed.  */
@@ -3497,6 +3515,9 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
                  /* Initialize _vptr to declared type.  */
                  gfc_symbol *vtab = gfc_find_derived_vtab (sym->ts.u.derived);
                  tree rhs;
+
+                 gfc_save_backend_locus (&loc);
+                 gfc_set_backend_locus (&sym->declared_at);
                  e = gfc_lval_expr_from_sym (sym);
                  gfc_add_vptr_component (e);
                  gfc_init_se (&se, NULL);
@@ -3506,6 +3527,7 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
                  rhs = gfc_build_addr_expr (TREE_TYPE (se.expr),
                                             gfc_get_symbol_decl (vtab));
                  gfc_add_modify (&init, se.expr, rhs);
+                 gfc_restore_backend_locus (&loc);
                }
 
              gfc_add_init_cleanup (block, gfc_finish_block (&init), tmp);