This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
RE: [Patch, fortran] PR15809 (PR19276) - ICE and segfault with au toma tic character, dummy pointer arrays
- From: THOMAS Paul Richard 169137 <paul dot richard dot thomas at cea dot fr>
- To: "'Paul Thomas'" <paulthomas2 at wanadoo dot fr>, Janne Blomqvist <jblomqvi at cc dot hut dot fi>
- Cc: gcc-patches at gcc dot gnu dot org, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Wed, 30 Nov 2005 12:30:13 +0100
- Subject: RE: [Patch, fortran] PR15809 (PR19276) - ICE and segfault with au toma tic character, dummy pointer arrays
Janne,
Apropos my earlier remark:
"Having a delay, due to last night's regtest problems, has had its
beneficial side; I just found the "correct" and infinitely more hygenic way
of implementing the element size in gfc_get_symbol_decl. I will test and
resubmit this afternoon. I hadn't got eyes for looking, when I first looked
for the right helper functions to do this!"
The "correctness" was an aberration on my part, brought on by caffeine
deficiency.
However, I have cleaned up this bit of code so that it is more hygenic;
please find the diff below. I will commit this version tonight, after
regtesting on FC3, since it is functionally identical to the original. Note
that the gcc_assert has disappeared, since gfc_get_element_type has this
more than adequately covered.
Cheers
Paul
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c (révision 107600)
+++ gcc/fortran/trans-decl.c (copie de travail)
@@ -810,6 +810,8 @@
{
tree decl;
tree length = NULL_TREE;
+ tree etype;
+ tree tmp;
int byref;
gcc_assert (sym->attr.referenced);
@@ -845,6 +847,22 @@
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);
}
}