diff options
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r-- | gcc/fortran/trans-decl.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 37e9db8..63320ae 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -809,7 +809,9 @@ tree gfc_get_symbol_decl (gfc_symbol * sym) { tree decl; + tree etype = NULL_TREE; tree length = NULL_TREE; + tree tmp = NULL_TREE; int byref; gcc_assert (sym->attr.referenced); @@ -845,6 +847,22 @@ gfc_get_symbol_decl (gfc_symbol * sym) if (TREE_CODE (length) != INTEGER_CST) { gfc_finish_var_decl (length, sym); + + /* Set the element size of automatic character length + length, dummy, pointer arrays. */ + if (sym->attr.pointer && sym->attr.dummy + && sym->attr.dimension) + { + tmp = gfc_build_indirect_ref (sym->backend_decl); + etype = gfc_get_element_type (TREE_TYPE (tmp)); + if (TYPE_SIZE_UNIT (etype) == NULL_TREE) + { + tmp = TYPE_SIZE_UNIT (gfc_character1_type_node); + tmp = fold_convert (TREE_TYPE (tmp), length); + TYPE_SIZE_UNIT (etype) = tmp; + } + } + gfc_defer_symbol_init (sym); } } |