Replying to myself:

Am 15.07.24 um 19:35 schrieb Harald Anlauf:
For '_len_trim_c_k':

Breakpoint 1, gfc_create_module_variable (sym=0x32af2f0)
     at ../../gcc-trunk/gcc/fortran/trans-decl.cc:5515
5515      gcc_assert (sym->ns->proc_name->attr.flavor == FL_MODULE
(gdb) p sym->ns->proc_name->attr.flavor
$9 = FL_PROCEDURE
(gdb) p sym->ns->parent->proc_name->attr.flavor
$10 = FL_PROCEDURE

This is not good.

Can we prevent the export of this artificial symbol?

Like this here (to give an idea, but otherwise untested):

diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 54ab60b4935..cc6ac7f192e 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -5455,6 +5468,13 @@ gfc_create_module_variable (gfc_symbol * sym)
        && !(sym->attr.flavor == FL_PROCEDURE && sym->attr.proc_pointer))
     return;

+  /* Do not output artificially created parameters.  */
+  if (sym->attr.flavor == FL_PARAMETER
+      && sym->name[0] == '_'
+      && sym->ns->proc_name->attr.flavor == FL_PROCEDURE
+      && sym->ns->parent->proc_name->attr.flavor == FL_PROCEDURE)
+    return;
+
   if ((sym->attr.in_common || sym->attr.in_equivalence) &&
sym->backend_decl)
     {
       decl = sym->backend_decl;

Maybe one might mark the symbol already at creation time and
detect this mark here, too.

Harald

Reply via email to