public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51808] New: Improve handling of ISO_C_BINDING binding names
@ 2012-01-10  9:50 jb at gcc dot gnu.org
  2012-01-13 21:23 ` [Bug fortran/51808] " jb at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-10  9:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51808

             Bug #: 51808
           Summary: Improve handling of ISO_C_BINDING binding names
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jb@gcc.gnu.org


Currently in gfc_symbol we have a field binding_label for the bind(C) binding
name. It is a char[] array of size 127. This is suboptimal because

1) For the vast majority of symbols which are not bind(C, name="XXX"), this
wastes memory.

2) It might be too short. Fortran limits the length of names to 63 characters,
but the binding name is not a Fortran identifier. The C standard says that the
implementation should support external identifiers with at least 31 characters,
but an implementation is free to support arbitrarily long identifiers.

Thus, we should get rid of the notion of limited binding label lengths, and use
dynamically allocated storage. 

Also, slightly related, for .mod files a non-empty binding_label field is
needed only if the default name is overridden, saving a bit of space.

If time permits, I'm planning to look into this for the 4.8 cycle.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51808] Improve handling of ISO_C_BINDING binding names
  2012-01-10  9:50 [Bug fortran/51808] New: Improve handling of ISO_C_BINDING binding names jb at gcc dot gnu.org
@ 2012-01-13 21:23 ` jb at gcc dot gnu.org
  2012-01-29 17:36 ` jb at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-13 21:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51808

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
                URL|                            |http://gcc.gnu.org/ml/gcc-p
                   |                            |atches/2012-01/msg00715.htm
                   |                            |l
   Last reconfirmed|                            |2012-01-13
         AssignedTo|unassigned at gcc dot       |jb at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-13 21:12:29 UTC ---
I have a patch: http://gcc.gnu.org/ml/gcc-patches/2012-01/msg00715.html


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51808] Improve handling of ISO_C_BINDING binding names
  2012-01-10  9:50 [Bug fortran/51808] New: Improve handling of ISO_C_BINDING binding names jb at gcc dot gnu.org
  2012-01-13 21:23 ` [Bug fortran/51808] " jb at gcc dot gnu.org
@ 2012-01-29 17:36 ` jb at gcc dot gnu.org
  2012-01-29 17:43 ` jb at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-29 17:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51808

--- Comment #2 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-29 17:19:38 UTC ---
Author: jb
Date: Sun Jan 29 17:19:32 2012
New Revision: 183677

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183677
Log:
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.


Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/match.h
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/fortran/trans-common.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/module_md5_1.f90


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51808] Improve handling of ISO_C_BINDING binding names
  2012-01-10  9:50 [Bug fortran/51808] New: Improve handling of ISO_C_BINDING binding names jb at gcc dot gnu.org
  2012-01-13 21:23 ` [Bug fortran/51808] " jb at gcc dot gnu.org
  2012-01-29 17:36 ` jb at gcc dot gnu.org
@ 2012-01-29 17:43 ` jb at gcc dot gnu.org
  2012-01-29 18:28 ` jb at gcc dot gnu.org
  2012-01-29 20:52 ` jb at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-29 17:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51808

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-29 17:24:52 UTC ---
Fixed, closing.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51808] Improve handling of ISO_C_BINDING binding names
  2012-01-10  9:50 [Bug fortran/51808] New: Improve handling of ISO_C_BINDING binding names jb at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-01-29 17:43 ` jb at gcc dot gnu.org
@ 2012-01-29 18:28 ` jb at gcc dot gnu.org
  2012-01-29 20:52 ` jb at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-29 18:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51808

--- Comment #4 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-29 17:41:54 UTC ---
Author: jb
Date: Sun Jan 29 17:41:49 2012
New Revision: 183678

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183678
Log:
PR 51808 Fix ChangeLog entry

Modified:
    trunk/gcc/fortran/ChangeLog


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug fortran/51808] Improve handling of ISO_C_BINDING binding names
  2012-01-10  9:50 [Bug fortran/51808] New: Improve handling of ISO_C_BINDING binding names jb at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2012-01-29 18:28 ` jb at gcc dot gnu.org
@ 2012-01-29 20:52 ` jb at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jb at gcc dot gnu.org @ 2012-01-29 20:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51808

--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> 2012-01-29 19:01:14 UTC ---
Author: jb
Date: Sun Jan 29 19:01:09 2012
New Revision: 183679

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183679
Log:
PR 51808 Constify binding_label.

2012-01-29  Janne Blomqvist  <jb@gcc.gnu.org>

    PR fortran/51808
    * decl.c (set_binding_label): Make binding_label argument const.
    (curr_binding_label): Constify.
    * gfortran.h (gfc_symbol): Constify binding_label.
    (gfc_common_head): Likewise.
    (get_iso_c_sym): Likewise.
    * match.c (gfc_match_name_C): Constify buffer argument.
    * match.h (gfc_match_name_C): Likewise.
    * resolve.c (set_name_and_label): Constify binding_label argument.
    (gfc_iso_c_sub_interface): Constify binding_label variable.
    * symbol.c (get_iso_c_sym): Constify binding_label argument.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/match.h
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-29 19:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-10  9:50 [Bug fortran/51808] New: Improve handling of ISO_C_BINDING binding names jb at gcc dot gnu.org
2012-01-13 21:23 ` [Bug fortran/51808] " jb at gcc dot gnu.org
2012-01-29 17:36 ` jb at gcc dot gnu.org
2012-01-29 17:43 ` jb at gcc dot gnu.org
2012-01-29 18:28 ` jb at gcc dot gnu.org
2012-01-29 20:52 ` jb at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).