diff options
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r-- | gcc/fortran/trans-decl.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index a73620f..5beb6f7 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1494,9 +1494,18 @@ gfc_get_symbol_decl (gfc_symbol * sym) gfc_internal_error ("intrinsic variable which isn't a procedure"); /* Create string length decl first so that they can be used in the - type declaration. */ + type declaration. For associate names, the target character + length is used. Set 'length' to a constant so that if the + string lenght is a variable, it is not finished a second time. */ if (sym->ts.type == BT_CHARACTER) - length = gfc_create_string_length (sym); + { + if (sym->attr.associate_var + && sym->ts.u.cl->backend_decl + && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL) + length = gfc_index_zero_node; + else + length = gfc_create_string_length (sym); + } /* Create the decl for the variable. */ decl = build_decl (sym->declared_at.lb->location, @@ -1558,6 +1567,8 @@ gfc_get_symbol_decl (gfc_symbol * sym) /* Character variables need special handling. */ gfc_allocate_lang_decl (decl); + /* Associate names can use the hidden string length variable + of their associated target. */ if (TREE_CODE (length) != INTEGER_CST) { gfc_finish_var_decl (length, sym); |