re PR fortran/32928 (DATA statement with array element as initializer is rejected)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Wed, 28 Nov 2007 01:02:36 +0000 (01:02 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Wed, 28 Nov 2007 01:02:36 +0000 (01:02 +0000)
2007-11-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR fortran/32928
* decl.c (match_data_constant): Use gfc_match_init_expr to match the
array spec and set the initializer expression.

From-SVN: r130484

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

index fcb03bc8385c763eaedfad40b19b068db34263ae..19eba467c665bf4268dee14fffc84842fd293f67 100644 (file)
@@ -1,3 +1,9 @@
+2007-11-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR fortran/32928
+       * decl.c (match_data_constant): Use gfc_match_init_expr to match the
+       array spec and set the initializer expression.
+
 2007-11-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/34227
index a35071b5655681368accbfaffe554fbad7a0c76a..0da9cd28a8f808bf8b6c95605d958eeb7818377d 100644 (file)
@@ -370,6 +370,30 @@ match_data_constant (gfc_expr **result)
   else if (sym->attr.flavor == FL_DERIVED)
     return gfc_match_structure_constructor (sym, result);
 
+  /* Check to see if the value is an initialization array expression.  */
+  if (sym->value->expr_type == EXPR_ARRAY)
+    {
+      gfc_current_locus = old_loc;
+
+      m = gfc_match_init_expr (result);
+      if (m == MATCH_ERROR)
+       return m;
+
+      if (m == MATCH_YES)
+       {
+         if (gfc_simplify_expr (*result, 0) == FAILURE)
+           m = MATCH_ERROR;
+
+         if ((*result)->expr_type == EXPR_CONSTANT)
+           return m;
+          else
+           {
+             gfc_error ("Invalid initializer %s in Data statement at %C", name);
+             return MATCH_ERROR;
+           }
+       }
+    }
+
   *result = gfc_copy_expr (sym->value);
   return MATCH_YES;
 }