diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-01-18 02:08:22 +0000 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2008-01-18 02:08:22 +0000 |
commit | 207bde5fcf3fe1c94704c79c123a9d730bd49f49 (patch) | |
tree | 0d870b6c1926c0dab0f36b7ab20630d7d863c637 /gcc | |
parent | 6c633d454a09f6fd5f85f54d46f57a733967c667 (diff) | |
download | gcc-207bde5fcf3fe1c94704c79c123a9d730bd49f49.zip gcc-207bde5fcf3fe1c94704c79c123a9d730bd49f49.tar.gz gcc-207bde5fcf3fe1c94704c79c123a9d730bd49f49.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/simplify.c | 39 |
2 files changed, 38 insertions, 8 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ad0ffcc..81feb21 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +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> PR fortran/33375 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 85d74a5..12be1e0 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -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. */ gfc_expr * @@ -3178,22 +3202,21 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, size_t nsource; gfc_expr *e; - /* Unpack the shape array. */ - if (source->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (source)) + /* Check that argument expression types are OK. */ + if (!is_constant_array_expr (source)) return NULL; - if (shape_exp->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (shape_exp)) + if (!is_constant_array_expr (shape_exp)) return NULL; - if (pad != NULL - && (pad->expr_type != EXPR_ARRAY || !gfc_is_constant_expr (pad))) + if (!is_constant_array_expr (pad)) return NULL; - if (order_exp != NULL - && (order_exp->expr_type != EXPR_ARRAY - || !gfc_is_constant_expr (order_exp))) + if (!is_constant_array_expr (order_exp)) return NULL; + /* Proceed with simplification, unpacking the array. */ + mpz_init (index); rank = 0; head = tail = NULL; |