aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-decl.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2019-10-27 15:00:54 +0000
committerPaul Thomas <pault@gcc.gnu.org>2019-10-27 15:00:54 +0000
commita9b64a615428ba6dad0dfe9b2d513a2d41db02dc (patch)
treef529983b606df8516f47036a249a070e14e67124 /gcc/fortran/trans-decl.c
parent051d8a5faa3b37b0dda84c8382174ee70d5b7992 (diff)
downloadgcc-a9b64a615428ba6dad0dfe9b2d513a2d41db02dc.zip
gcc-a9b64a615428ba6dad0dfe9b2d513a2d41db02dc.tar.gz
gcc-a9b64a615428ba6dad0dfe9b2d513a2d41db02dc.tar.bz2
re PR fortran/86248 (LEN_TRIM in specification expression causes link failure)
2019-10-27 Paul Thomas <pault@gcc.gnu.org> PR fortran/86248 * resolve.c (flag_fn_result_spec): Correct a typo before the function declaration. * trans-decl.c (gfc_sym_identifier): Boost the length of 'name' to allow for all variants. Simplify the code by using a pointer to the symbol's proc_name and taking the return out of each of the conditional branches. Allow symbols with fn_result_spec set that do not come from a procedure namespace and have a module name to go through the non-fn_result_spec branch. 2019-10-27 Paul Thomas <pault@gcc.gnu.org> PR fortran/86248 * gfortran.dg/char_result_19.f90 : New test. * gfortran.dg/char_result_mod_19.f90 : Module for the new test. From-SVN: r277487
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r--gcc/fortran/trans-decl.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index fc295b4..630682c 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -369,44 +369,37 @@ gfc_sym_identifier (gfc_symbol * sym)
static const char *
mangled_identifier (gfc_symbol *sym)
{
- static char name[GFC_MAX_MANGLED_SYMBOL_LEN + 1];
+ gfc_symbol *proc = sym->ns->proc_name;
+ static char name[3*GFC_MAX_MANGLED_SYMBOL_LEN + 14];
/* Prevent the mangling of identifiers that have an assigned
binding label (mainly those that are bind(c)). */
if (sym->attr.is_bind_c == 1 && sym->binding_label)
return sym->binding_label;
- if (!sym->fn_result_spec)
+ if (!sym->fn_result_spec
+ || (sym->module && !(proc && proc->attr.flavor == FL_PROCEDURE)))
{
if (sym->module == NULL)
return sym_identifier (sym);
else
- {
- snprintf (name, sizeof name, "__%s_MOD_%s", sym->module, sym->name);
- return name;
- }
+ snprintf (name, sizeof name, "__%s_MOD_%s", sym->module, sym->name);
}
else
{
/* This is an entity that is actually local to a module procedure
that appears in the result specification expression. Since
sym->module will be a zero length string, we use ns->proc_name
- instead. */
- if (sym->ns->proc_name && sym->ns->proc_name->module)
- {
- snprintf (name, sizeof name, "__%s_MOD__%s_PROC_%s",
- sym->ns->proc_name->module,
- sym->ns->proc_name->name,
- sym->name);
- return name;
- }
+ to provide the module name instead. */
+ if (proc && proc->module)
+ snprintf (name, sizeof name, "__%s_MOD__%s_PROC_%s",
+ proc->module, proc->name, sym->name);
else
- {
- snprintf (name, sizeof name, "__%s_PROC_%s",
- sym->ns->proc_name->name, sym->name);
- return name;
- }
+ snprintf (name, sizeof name, "__%s_PROC_%s",
+ proc->name, sym->name);
}
+
+ return name;
}
/* Get mangled identifier, adding the symbol to the global table if