Am 15.07.24 um 20:27 schrieb Harald Anlauf:
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.
JFTR: this regtests cleanly here.
While looking over the last version of the patch again,
the following should be corrected:
@@ -4637,6 +4637,75 @@ gfc_simplify_len_trim (gfc_expr *e, gfc_expr *kind)
if (k == -1)
return &gfc_bad_expr;
+ if (e->expr_type == EXPR_VARIABLE
+ && e->ts.type == BT_CHARACTER
+ && e->symtree->n.sym->attr.flavor == FL_PARAMETER
+ && e->ref && e->ref->type == REF_ARRAY
+ && e->ref->u.ar.dimen_type[0] == DIMEN_ELEMENT
+ && e->symtree->n.sym->value)
+ {
+ char name[2*GFC_MAX_SYMBOL_LEN + 10];
^^ this has to be 12 now
+ gfc_namespace *ns = e->symtree->n.sym->ns;
+ gfc_symtree *st;
+ gfc_expr *expr;
+ gfc_expr *p;
+ gfc_constructor *c;
+ int cnt = 0;
+
+ sprintf (name, "_len_trim_%s_%s", e->symtree->n.sym->name,
ns->proc_name->name);
Cheers,
Harald