Patch to gfortran 15393/15370
Paul Brook
paul@codesourcery.com
Sat May 15 18:22:00 GMT 2004
On Wednesday 12 May 2004 15:56, Victor Leikehman wrote:
> (Apparently my original posting did not make it through.
> My apologies if you get this twice).
>
> In fortran, initialization of automatic arrays is not permitted
> and should be rejected by front end (currently triggers ICE).
You patch still ICEd on things like
integer, dimension(:) :: a = 1
I've fixed and applied as follows.
Paul
2004-05-15 Victor Leikehman <lei@haifasphere.co.il>
* decl.c (add_init_expr_to_sym): Check for variable size arrays.
Index: decl.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/decl.c,v
retrieving revision 1.2
diff -u -p -r1.2 decl.c
--- a/decl.c 13 May 2004 06:40:29 -0000 1.2
+++ b/decl.c 15 May 2004 18:17:25 -0000
@@ -254,6 +254,7 @@ static try
add_init_expr_to_sym (const char *name, gfc_expr ** initp,
locus * var_locus)
{
+ int i;
symbol_attribute attr;
gfc_symbol *sym;
gfc_expr *init;
@@ -301,6 +302,19 @@ add_init_expr_to_sym (const char *name,
&& gfc_check_assign_symbol (sym, init) == FAILURE)
return FAILURE;
+ for (i = 0; i < sym->attr.dimension; i++)
+ {
+ if (sym->as->lower[i] == NULL
+ || sym->as->lower[i]->expr_type != EXPR_CONSTANT
+ || sym->as->upper[i] == NULL
+ || sym->as->upper[i]->expr_type != EXPR_CONSTANT)
+ {
+ gfc_error ("Array '%s' at %C cannot have initializer",
+ sym->name);
+ return FAILURE;
+ }
+ }
+
/* Add initializer. Make sure we keep the ranks sane. */
if (sym->attr.dimension && init->rank == 0)
init->rank = sym->as->rank;
More information about the Fortran
mailing list