diff options
Diffstat (limited to 'gcc/fortran/trans-stmt.c')
-rw-r--r-- | gcc/fortran/trans-stmt.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c index 96e5abd..7e0e856 100644 --- a/gcc/fortran/trans-stmt.c +++ b/gcc/fortran/trans-stmt.c @@ -5167,7 +5167,16 @@ gfc_trans_allocate (gfc_code * code) se_sz.expr = gfc_evaluate_now (se_sz.expr, &se.pre); gfc_add_block_to_block (&se.pre, &se_sz.post); /* Store the string length. */ - tmp = al->expr->ts.u.cl->backend_decl; + if ((expr->symtree->n.sym->ts.type == BT_CLASS + || expr->symtree->n.sym->ts.type == BT_DERIVED) + && expr->ts.u.derived->attr.unlimited_polymorphic) + /* For unlimited polymorphic entities get the backend_decl of + the _len component for that. */ + tmp = gfc_class_len_get (gfc_get_symbol_decl ( + expr->symtree->n.sym)); + else + /* Else use what is stored in the charlen->backend_decl. */ + tmp = al->expr->ts.u.cl->backend_decl; gfc_add_modify (&se.pre, tmp, fold_convert (TREE_TYPE (tmp), se_sz.expr)); tmp = TREE_TYPE (gfc_typenode_for_spec (&code->ext.alloc.ts)); |