On 18.01.2012 10:12, Tobias Burnus wrote:

Dear Janne,

the attached patch changes the binding labels that are needed for
bind(C) symbols to be heap allocated rather than, as currently, being
fixed size arrays of size 127 (or 64 in module.c!?).

  wonder whether it would have been smarter to use string matching rather
than the manual matching in gfc_match_name_C to obtain longer strings.
(Cf. PR 36275. Different but related binding label issue: PR 38839.)
On the other hand, that's separate issues, deserving patches on their own.


--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -2744,14 +2747,16 @@ gfc_iso_c_func_interface (gfc_symbol *sym,
        {
          /* two args.  */
          sprintf (name, "%s_2", sym->name);
-         sprintf (binding_label, "%s_2", sym->binding_label);
+         if (sym->binding_label)
+           sprintf (binding_label, "%s_2", sym->binding_label);
          optional_arg = 1;

I wonder whether one can get rid of all those binding names. I think
they date back to the time when a libgfortran function was called for
ISOCBINDING_ASSOCIATED instead of just generating in trans-intrinsics.c
one (ptr != NULL) or two (ptr != NULL&&  ptr == tgt) pointer comparisons.
I also believe that C_LOC and C_FUNLOC are (now) handled in
trans-intrinsics.c. Thus, you could confirm that no binding name is
needed and remove them.


Otherwise, the patch looks relatively mechnical and is OK.

Tobias

Hello,

We could consider using gfc_get_string (instead of the many strcpy) to ease memory management.

Mikael

Reply via email to