aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r--gcc/fortran/trans-decl.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index c4cdcd6..1fe1165 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1572,13 +1572,17 @@ gfc_get_symbol_decl (gfc_symbol * sym)
if (VAR_P (length) && DECL_FILE_SCOPE_P (length))
{
/* Add the string length to the same context as the symbol. */
- if (DECL_CONTEXT (sym->backend_decl) == current_function_decl)
- gfc_add_decl_to_function (length);
- else
- gfc_add_decl_to_parent_function (length);
+ if (DECL_CONTEXT (length) == NULL_TREE)
+ {
+ if (DECL_CONTEXT (sym->backend_decl)
+ == current_function_decl)
+ gfc_add_decl_to_function (length);
+ else
+ gfc_add_decl_to_parent_function (length);
+ }
- gcc_assert (DECL_CONTEXT (sym->backend_decl) ==
- DECL_CONTEXT (length));
+ gcc_assert (DECL_CONTEXT (sym->backend_decl)
+ == DECL_CONTEXT (length));
gfc_defer_symbol_init (sym);
}