+2005-12-01 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/24789
+ * trans-decl.c (gfc_get_symbol_decl): Move the expression for
+ unit size of automatic character length, dummy pointer array
+ elements down a few lines from the version that fixed PR15809.
+
2005-11-30 Bernhard Fischer <rep.nop@aon.at>
PR fortran/21302
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);
}
}
+
+ /* Set the element size of automatic and assumed 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), sym->ts.cl->backend_decl);
+ TYPE_SIZE_UNIT (etype) = tmp;
+ }
+ }
}
/* Use a copy of the descriptor for dummy arrays. */
--- /dev/null
+! { dg-do compile }
+! Test fix for pr24789 - would segfault on the assignment
+! because the array descriptor size was not set.
+!
+! This is the example submitted by Martin Reineke <martin@mpa-garching.mpg.de>
+
+subroutine foo(vals)
+ character(len = *), pointer :: vals(:)
+ vals = ''
+end subroutine
+