OSDN Git Service

* decl.c (add_init_expr_to_sym): Check for variable size arrays.
authorpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 15 May 2004 18:20:09 +0000 (18:20 +0000)
committerpbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 15 May 2004 18:20:09 +0000 (18:20 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@81894 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/decl.c

index 549b82d..00e6be2 100644 (file)
@@ -1,3 +1,7 @@
+2004-05-15  Victor Leikehman  <lei@haifasphere.co.il>
+
+       * decl.c (add_init_expr_to_sym): Check for variable size arrays.
+
 2004-05-15  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * primary.c (match_boz_constant): Use gfc_notify_std() for
index 2aed9b2..c36c7ba 100644 (file)
@@ -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;
@@ -287,7 +288,7 @@ add_init_expr_to_sym (const char *name, gfc_expr ** initp,
   else
     {
       /* If a variable appears in a DATA block, it cannot have an
-         initializer.  */
+        initializer.  */
       if (sym->attr.data)
        {
          gfc_error
@@ -301,6 +302,19 @@ add_init_expr_to_sym (const char *name, gfc_expr ** initp,
          && 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;