diff options
author | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-29 17:19:32 +0000 |
---|---|---|
committer | jb <jb@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-01-29 17:19:32 +0000 |
commit | 7b2060ba65acd2fdcbf0dedd5ad0a268b2028b51 (patch) | |
tree | 9cf48d558f50c1053b18c202c9c36d7a8a46c9f8 /gcc/fortran/symbol.c | |
parent | 3e6bf5fe04413ffdcf981bf74684309cb7cf6800 (diff) | |
download | gcc-7b2060ba65acd2fdcbf0dedd5ad0a268b2028b51.tar.gz |
PR 51808 Support arbitrarily long bind(C) binding labels.
2012-01-29 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/51808
* decl.c (set_binding_label): Move prototype from match.h to here.
(curr_binding_label): Make a pointer rather than static array.
(build_sym): Check sym->binding_label pointer rather than array,
update set_binding_label call, handle curr_binding_label changes.
(set_binding_label): Handle new curr_binding_label, dest_label
double ptr, and sym->binding_label.
(verify_bind_c_sym): Handle sym->binding_label being a pointer.
(set_verify_bind_c_sym): Check sym->binding_label pointer rather
than array, update set_binding_label call.
(gfc_match_bind_c_stmt): Handle curr_binding_label change.
(match_procedure_decl): Update set_binding_label call.
(gfc_match_bind_c): Change binding_label to pointer, update
gfc_match_name_C call.
* gfortran.h (GFC_MAX_BINDING_LABEL_LEN): Remove macro.
(gfc_symbol): Make binding_label a pointer.
(gfc_common_head): Likewise.
* match.c (gfc_match_name_C): Heap allocate bind(C) name.
* match.h (gfc_match_name_C): Change prototype argument.
(set_binding_label): Move prototype to decl.c.
* module.c (struct pointer_info): Make binding_label a pointer.
(free_pi_tree): Free unused binding_label.
(mio_read_string): New function.
(mio_write_string): New function.
(load_commons): Redo reading of binding_label.
(read_module): Likewise.
(write_common_0): Change to write empty string instead of name if
no binding_label.
(write_blank_common): Write empty string for binding label.
(write_symbol): Change to write empty string instead of name if no
binding_label.
* resolve.c (gfc_iso_c_func_interface): Don't set binding_label.
(set_name_and_label): Make binding_label double pointer, use
asprintf.
(gfc_iso_c_sub_interface): Make binding_label a pointer.
(resolve_bind_c_comms): Handle cases if
gfc_common_head->binding_label is NULL.
(gfc_verify_binding_labels): sym->binding_label is a pointer.
* symbol.c (gfc_free_symbol): Free binding_label.
(gfc_new_symbol): Rely on XCNEW zero init for binding_label.
(gen_special_c_interop_ptr): Don't set binding label.
(generate_isocbinding_symbol): Insert binding_label into symbol
table.
(get_iso_c_sym): Use pointer assignment instead of strcpy.
* trans-common.c (gfc_sym_mangled_common_id): Handle
com->binding_label being a pointer.
* trans-decl.c (gfc_sym_mangled_identifier): Handle
sym->binding_label being a pointer.
(gfc_sym_mangled_function_id): Likewise.
testsuite ChangeLog
2012-01-29 Janne Blomqvist <jb@gcc.gnu.org>
PR fortran/51808
* gfortran.dg/module_md5_1.f90: Update MD5 sum.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183677 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/symbol.c')
-rw-r--r-- | gcc/fortran/symbol.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 36fc1ed562b..e13e1df0d33 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -1,6 +1,6 @@ /* Maintain binary trees of symbols. Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, - 2009, 2010, 2011 + 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Andy Vaught @@ -2556,8 +2556,6 @@ gfc_new_symbol (const char *name, gfc_namespace *ns) /* Make sure flags for symbol being C bound are clear initially. */ p->attr.is_bind_c = 0; p->attr.is_iso_c = 0; - /* Make sure the binding label field has a Nul char to start. */ - p->binding_label[0] = '\0'; /* Clear the ptrs we may need. */ p->common_block = NULL; @@ -3805,8 +3803,8 @@ gen_special_c_interop_ptr (int ptr_id, const char *ptr_name, tmp_sym->attr.use_assoc = 1; tmp_sym->attr.is_bind_c = 1; - /* Set the binding_label. */ - sprintf (tmp_sym->binding_label, "%s_%s", module_name, tmp_sym->name); + /* Since we never generate a call to this symbol, don't set the + binding_label. */ /* Set the c_address field of c_null_ptr and c_null_funptr to the value of NULL. */ @@ -4588,8 +4586,9 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s, /* Use the procedure's name as it is in the iso_c_binding module for setting the binding label in case the user renamed the symbol. */ - sprintf (tmp_sym->binding_label, "%s_%s", mod_name, - c_interop_kinds_table[s].name); + tmp_sym->binding_label = + gfc_get_string ("%s_%s", mod_name, + c_interop_kinds_table[s].name); tmp_sym->attr.is_iso_c = 1; if (s == ISOCBINDING_F_POINTER || s == ISOCBINDING_F_PROCPOINTER) tmp_sym->attr.subroutine = 1; @@ -4702,7 +4701,7 @@ get_iso_c_sym (gfc_symbol *old_sym, char *new_name, "symtree for '%s'", new_name); /* Now fill in the fields of the resolved symbol with the old sym. */ - strcpy (new_symtree->n.sym->binding_label, new_binding_label); + new_symtree->n.sym->binding_label = new_binding_label; new_symtree->n.sym->attr = old_sym->attr; new_symtree->n.sym->ts = old_sym->ts; new_symtree->n.sym->module = gfc_get_string (old_sym->module); |