2010-10-06 Mikael Morin <mikael@gcc.gnu.org>
authormikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 Oct 2010 15:48:25 +0000 (15:48 +0000)
committermikael <mikael@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 Oct 2010 15:48:25 +0000 (15:48 +0000)
* trans.c (gfc_restore_backend_locus): New function.
(gfc_get_backend_locus): Renamed to ...
(gfc_save_backend_locus): ... this.
* trans.h (gfc_restore_backend_locus, gfc_get_backend_locus,
gfc_save_backend_locus): Same.
* trans-array.c (gfc_trans_g77_array, gfc_trans_dummy_array_bias,
gfc_trans_deferred_array): Rename gfc_get_backend_locus to
gfc_save_backend_locus.
(gfc_trans_dummy_array_bias): Call gfc_restore_backend_locus at the
end.
(gfc_trans_g77_array, gfc_trans_deferred_array): Use
gfc_restore_backend_locus instead of gfc_set_backend_locus.
(gfc_trans_deferred_array): Call gfc_restore_backend_locus on early
return.
* trans-decl.c (gfc_get_extern_function_decl, build_entry_thunks,
gfc_trans_deferred_vars):
Rename gfc_get_backend_locus to gfc_save_backend_locus.
Use gfc_restore_backend_locus insted of gfc_set_backend_locus.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165045 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 27ed63c..384842d 100644 (file)
@@ -1,5 +1,26 @@
 2010-10-06  Mikael Morin  <mikael@gcc.gnu.org>
 
+       * trans.c (gfc_restore_backend_locus): New function.
+       (gfc_get_backend_locus): Renamed to ...
+       (gfc_save_backend_locus): ... this.
+       * trans.h (gfc_restore_backend_locus, gfc_get_backend_locus,
+       gfc_save_backend_locus): Same.
+       * trans-array.c (gfc_trans_g77_array, gfc_trans_dummy_array_bias,
+       gfc_trans_deferred_array): Rename gfc_get_backend_locus to
+       gfc_save_backend_locus.
+       (gfc_trans_dummy_array_bias): Call gfc_restore_backend_locus at the
+       end.
+       (gfc_trans_g77_array, gfc_trans_deferred_array): Use
+       gfc_restore_backend_locus instead of gfc_set_backend_locus.
+       (gfc_trans_deferred_array): Call gfc_restore_backend_locus on early
+       return.
+       * trans-decl.c (gfc_get_extern_function_decl, build_entry_thunks,
+       gfc_trans_deferred_vars):
+       Rename gfc_get_backend_locus to gfc_save_backend_locus.
+       Use gfc_restore_backend_locus insted of gfc_set_backend_locus.
+
+2010-10-06  Mikael Morin  <mikael@gcc.gnu.org>
+
        * trans-array.c (gfc_build_constant_array_constructor): Free array
        spec when done.
 
index 93d9b79..271b37c 100644 (file)
@@ -4536,10 +4536,10 @@ gfc_trans_g77_array (gfc_symbol * sym, gfc_wrapped_block * block)
   locus loc;
   tree offset;
   tree tmp;
-  tree stmt;  
+  tree stmt;
   stmtblock_t init;
 
-  gfc_get_backend_locus (&loc);
+  gfc_save_backend_locus (&loc);
   gfc_set_backend_locus (&sym->declared_at);
 
   /* Descriptor type.  */
@@ -4568,7 +4568,7 @@ gfc_trans_g77_array (gfc_symbol * sym, gfc_wrapped_block * block)
     }
   stmt = gfc_finish_block (&init);
 
-  gfc_set_backend_locus (&loc);
+  gfc_restore_backend_locus (&loc);
 
   /* Add the initialization code to the start of the function.  */
 
@@ -4629,7 +4629,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc,
       return;
     }
 
-  gfc_get_backend_locus (&loc);
+  gfc_save_backend_locus (&loc);
   gfc_set_backend_locus (&sym->declared_at);
 
   /* Descriptor type.  */
@@ -4921,6 +4921,8 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc,
   /* We don't need to free any memory allocated by internal_pack as it will
      be freed at the end of the function by pop_context.  */
   gfc_add_init_cleanup (block, stmtInit, stmtCleanup);
+
+  gfc_restore_backend_locus (&loc);
 }
 
 
@@ -6500,7 +6502,7 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
       return;
     }
 
-  gfc_get_backend_locus (&loc);
+  gfc_save_backend_locus (&loc);
   gfc_set_backend_locus (&sym->declared_at);
   descriptor = sym->backend_decl;
 
@@ -6513,6 +6515,7 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
       gfc_trans_static_array_pointer (sym);
 
       gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
+      gfc_restore_backend_locus (&loc);
       return;
     }
 
@@ -6550,7 +6553,7 @@ gfc_trans_deferred_array (gfc_symbol * sym, gfc_wrapped_block * block)
     gfc_conv_descriptor_data_set (&init, descriptor, null_pointer_node);
 
   gfc_init_block (&cleanup);
-  gfc_set_backend_locus (&loc);
+  gfc_restore_backend_locus (&loc);
 
   /* Allocatable arrays need to be freed when they go out of scope.
      The allocatable components of pointers must not be touched.  */
index ddcc735..2356792 100644 (file)
@@ -1454,13 +1454,13 @@ gfc_get_extern_function_decl (gfc_symbol * sym)
          tree save_fn_decl = current_function_decl;
 
          current_function_decl = NULL_TREE;
-         gfc_get_backend_locus (&old_loc);
+         gfc_save_backend_locus (&old_loc);
          push_cfun (cfun);
 
          gfc_create_function_decl (gsym->ns, true);
 
          pop_cfun ();
-         gfc_set_backend_locus (&old_loc);
+         gfc_restore_backend_locus (&old_loc);
          current_function_decl = save_fn_decl;
        }
 
@@ -2028,7 +2028,7 @@ build_entry_thunks (gfc_namespace * ns, bool global)
   /* This should always be a toplevel function.  */
   gcc_assert (current_function_decl == NULL_TREE);
 
-  gfc_get_backend_locus (&old_loc);
+  gfc_save_backend_locus (&old_loc);
   for (el = ns->entries; el; el = el->next)
     {
       VEC(tree,gc) *args = NULL;
@@ -2192,7 +2192,7 @@ build_entry_thunks (gfc_namespace * ns, bool global)
        }
     }
 
-  gfc_set_backend_locus (&old_loc);
+  gfc_restore_backend_locus (&old_loc);
 }
 
 
@@ -3336,11 +3336,11 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
                                            NULL_TREE);
                    }
 
-                 gfc_get_backend_locus (&loc);
+                 gfc_save_backend_locus (&loc);
                  gfc_set_backend_locus (&sym->declared_at);
                  gfc_trans_auto_array_allocation (sym->backend_decl,
                                                   sym, block);
-                 gfc_set_backend_locus (&loc);
+                 gfc_restore_backend_locus (&loc);
                }
              break;
 
@@ -3412,20 +3412,20 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
        gfc_trans_deferred_array (sym, block);
       else if (sym->ts.type == BT_CHARACTER)
        {
-         gfc_get_backend_locus (&loc);
+         gfc_save_backend_locus (&loc);
          gfc_set_backend_locus (&sym->declared_at);
          if (sym->attr.dummy || sym->attr.result)
            gfc_trans_dummy_character (sym, sym->ts.u.cl, block);
          else
            gfc_trans_auto_character_variable (sym, block);
-         gfc_set_backend_locus (&loc);
+         gfc_restore_backend_locus (&loc);
        }
       else if (sym->attr.assign)
        {
-         gfc_get_backend_locus (&loc);
+         gfc_save_backend_locus (&loc);
          gfc_set_backend_locus (&sym->declared_at);
          gfc_trans_assign_aux_var (sym, block);
-         gfc_set_backend_locus (&loc);
+         gfc_restore_backend_locus (&loc);
        }
       else if (sym->ts.type == BT_DERIVED
                 && sym->value
index 117d345..a9513af 100644 (file)
@@ -1055,11 +1055,11 @@ gfc_add_block_to_block (stmtblock_t * block, stmtblock_t * append)
 }
 
 
-/* Get the current locus.  The structure may not be complete, and should
-   only be used with gfc_set_backend_locus.  */
+/* Save the current locus.  The structure may not be complete, and should
+   only be used with gfc_restore_backend_locus.  */
 
 void
-gfc_get_backend_locus (locus * loc)
+gfc_save_backend_locus (locus * loc)
 {
   loc->lb = XCNEW (gfc_linebuf);
   loc->lb->location = input_location;
@@ -1077,6 +1077,17 @@ gfc_set_backend_locus (locus * loc)
 }
 
 
+/* Restore the saved locus. Only used in conjonction with
+   gfc_save_backend_locus, to free the memory when we are done.  */
+
+void
+gfc_restore_backend_locus (locus * loc)
+{
+  gfc_set_backend_locus (loc);
+  gfc_free (loc->lb);
+}
+
+
 /* Translate an executable statement. The tree cond is used by gfc_trans_do.
    This static function is wrapped by gfc_trans_code_cond and
    gfc_trans_code.  */
index a883cf5..b3c6032 100644 (file)
@@ -491,8 +491,9 @@ struct module_htab_entry *gfc_find_module (const char *);
 void gfc_module_add_decl (struct module_htab_entry *, tree);
 
 /* Get and set the current location.  */
+void gfc_save_backend_locus (locus *);
 void gfc_set_backend_locus (locus *);
-void gfc_get_backend_locus (locus *);
+void gfc_restore_backend_locus (locus *);
 
 /* Handle static constructor functions.  */
 extern GTY(()) tree gfc_static_ctors;