Patchwork [fortran,3/4] C binding access to C_PTR type: don't do name lookup in gen_special_c_interop_ptr

login
register
mail settings
Submitter Mikael Morin
Date March 2, 2013, 4:54 p.m.
Message ID <20130302165418.10658.13936@marvin>
Download mbox | patch
Permalink /patch/224516/
State New
Headers show

Comments

Mikael Morin - March 2, 2013, 4:54 p.m.
This patch fixes gen_special_c_interop_ptr, which uses gfc_find_symtree to retrieve
the current symbol.  Again, this is not safe to renaming and hiding, so this
patch passes the symbol directly, instead of passing its name and retrieving
the symbol from it.
2013-03-02  Mikael Morin  <mikael@gcc.gnu.org>

	* symbol.c (gen_special_c_interop_ptr):  Retrieve symbol through
	argument instead of symbol name lookup.
	(generate_isocbinding_symbol): Update caller.

Patch

diff --git a/symbol.c b/symbol.c
index 646ca9d..b03d572 100644
--- a/symbol.c
+++ b/symbol.c
@@ -3811,25 +3811,12 @@  verify_bind_c_derived_type (gfc_symbol *derived_sym)
 /* Generate symbols for the named constants c_null_ptr and c_null_funptr.  */
 
 static gfc_try
-gen_special_c_interop_ptr (int ptr_id, const char *ptr_name,
-                           const char *module_name)
+gen_special_c_interop_ptr (int ptr_id, gfc_symbol *tmp_sym,
+			   const char *module_name)
 {
-  gfc_symtree *tmp_symtree;
-  gfc_symbol *tmp_sym;
   gfc_constructor *c;
   iso_c_binding_symbol type_id;
 
-  tmp_symtree = gfc_find_symtree (gfc_current_ns->sym_root, ptr_name);
-	 
-  if (tmp_symtree != NULL)
-    tmp_sym = tmp_symtree->n.sym;
-  else
-    {
-      tmp_sym = NULL;
-      gfc_internal_error ("gen_special_c_interop_ptr(): Unable to "
-                          "create symbol for %s", ptr_name);
-    }
-
   tmp_sym->ts.is_c_interop = 1;
   tmp_sym->attr.is_c_interop = 1;
   tmp_sym->ts.is_iso_c = 1;
@@ -4507,8 +4494,8 @@  generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s,
 
       case ISOCBINDING_NULL_PTR:
       case ISOCBINDING_NULL_FUNPTR:
-        gen_special_c_interop_ptr (s, name, mod_name);
-        break;
+	gen_special_c_interop_ptr (s, tmp_sym, mod_name);
+	break;
 
       case ISOCBINDING_F_POINTER:
       case ISOCBINDING_ASSOCIATED: