https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103828

--- Comment #1 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
The condition for being treated as a special CHARACTER case in gfc_sym_type()
is:

  if (sym->ts.type == BT_CHARACTER
      && ((sym->attr.function && sym->attr.is_bind_c)
          || (sym->attr.result
              && sym->ns->proc_name
              && sym->ns->proc_name->attr.is_bind_c)
          || (sym->ts.deferred && (!sym->ts.u.cl
                                   || !sym->ts.u.cl->backend_decl))))

Here we're not a function, not a result variable, we don't have
sym->ts.deferred.

I am thinking we may want to do this:

--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2262,14 +2262,14 @@ gfc_sym_type (gfc_symbol * sym, bool is_bind_c)

   if (sym->ts.type == BT_CHARACTER
       && ((sym->attr.function && sym->attr.is_bind_c)
-         || (sym->attr.result
+         || ((sym->attr.result || sym->attr.value)
              && sym->ns->proc_name
              && sym->ns->proc_name->attr.is_bind_c)
          || (sym->ts.deferred && (!sym->ts.u.cl
                                   || !sym->ts.u.cl->backend_decl))))

But while it does give the propre tree-type, it does not fix the global issue.

Reply via email to