This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Patch to gfortran 15393/15370
- From: Paul Brook <paul at codesourcery dot com>
- To: fortran at gcc dot gnu dot org
- Cc: Victor Leikehman <LEI at il dot ibm dot com>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 15 May 2004 19:21:59 +0100
- Subject: Re: Patch to gfortran 15393/15370
- Organization: CodeSourcery
- References: <OF253B971B.28928C6A-ON43256E92.00518B1D-43256E92.00520B82@il.ibm.com>
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;