Commit 207bde5f by Jerry DeLisle

re PR fortran/34556 (Rejects valid with bogus error message: parameter initalization)

2008-01-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/34556
	* simplify.c (is_constant_array_expr): New static function that returns
	true if the given expression is an array and is constant.
	(gfc_simplify_reshape): Use new function.

From-SVN: r131623
parent 6c633d45
2008-01-17 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/34556
* simplify.c (is_constant_array_expr): New static function that returns
true if the given expression is an array and is constant.
(gfc_simplify_reshape): Use new function.
2008-01-17 H.J. Lu <hongjiu.lu@intel.com> 2008-01-17 H.J. Lu <hongjiu.lu@intel.com>
PR fortran/33375 PR fortran/33375
......
...@@ -3164,6 +3164,30 @@ gfc_simplify_repeat (gfc_expr *e, gfc_expr *n) ...@@ -3164,6 +3164,30 @@ gfc_simplify_repeat (gfc_expr *e, gfc_expr *n)
} }
/* Test that the expression is an constant array. */
static bool
is_constant_array_expr (gfc_expr *e)
{
gfc_constructor *c;
if (e == NULL)
return true;
if (e->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (e))
return false;
if (e->value.constructor == NULL)
return false;
for (c = e->value.constructor; c; c = c->next)
if (c->expr->expr_type != EXPR_CONSTANT)
return false;
return true;
}
/* This one is a bear, but mainly has to do with shuffling elements. */ /* This one is a bear, but mainly has to do with shuffling elements. */
gfc_expr * gfc_expr *
...@@ -3178,22 +3202,21 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, ...@@ -3178,22 +3202,21 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp,
size_t nsource; size_t nsource;
gfc_expr *e; gfc_expr *e;
/* Unpack the shape array. */ /* Check that argument expression types are OK. */
if (source->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (source)) if (!is_constant_array_expr (source))
return NULL; return NULL;
if (shape_exp->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (shape_exp)) if (!is_constant_array_expr (shape_exp))
return NULL; return NULL;
if (pad != NULL if (!is_constant_array_expr (pad))
&& (pad->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (pad)))
return NULL; return NULL;
if (order_exp != NULL if (!is_constant_array_expr (order_exp))
&& (order_exp->expr_type != EXPR_ARRAY
|| !gfc_is_constant_expr (order_exp)))
return NULL; return NULL;
/* Proceed with simplification, unpacking the array. */
mpz_init (index); mpz_init (index);
rank = 0; rank = 0;
head = tail = NULL; head = tail = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment