summaryrefslogtreecommitdiff
path: root/gcc/fortran/array.c
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-09 17:47:04 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2010-01-09 17:47:04 +0000
commitc315461d1a22ed500bc4d1f2897dddcb77a9e011 (patch)
treefaf22ebd02e6d70418500dc89807d3068c3b0ad2 /gcc/fortran/array.c
parent7368569212f3e0ab9a02ad46b5721b760ea5971d (diff)
downloadgcc-c315461d1a22ed500bc4d1f2897dddcb77a9e011.tar.gz
2010-01-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/20923 PR fortran/32489 * trans-array.c (gfc_conv_array_initializer): Change call to gfc_error_now to call to gfc_fatal_error. * array.c (count_elements): Whitespace. (extract_element): Whitespace. (is_constant_element): Changed name from constant_element. (gfc_constant_ac): Only use expand_construuctor for expression types of EXPR_ARRAY. If expression type is EXPR_CONSTANT, no need to call gfc_is_constant_expr. * expr.c (gfc_reduce_init_expr): Adjust conditionals and delete error message. * resolve.c (gfc_is_expandable_expr): New function that determiners if array expressions should have their constructors expanded. (gfc_resolve_expr): Use new function to determine whether or not to call gfc_expand_constructor. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155769 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/array.c')
-rw-r--r--gcc/fortran/array.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index e1a5f25badf..7bb51003418 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -1237,7 +1237,6 @@ count_elements (gfc_expr *e)
static gfc_try
extract_element (gfc_expr *e)
{
-
if (e->rank != 0)
{ /* Something unextractable */
gfc_free_expr (e);
@@ -1250,6 +1249,7 @@ extract_element (gfc_expr *e)
gfc_free_expr (e);
current_expand.extract_count++;
+
return SUCCESS;
}
@@ -1495,7 +1495,7 @@ done:
FAILURE if not so. */
static gfc_try
-constant_element (gfc_expr *e)
+is_constant_element (gfc_expr *e)
{
int rv;
@@ -1517,14 +1517,38 @@ gfc_constant_ac (gfc_expr *e)
{
expand_info expand_save;
gfc_try rc;
+ gfc_constructor * con;
+
+ rc = SUCCESS;
- iter_stack = NULL;
- expand_save = current_expand;
- current_expand.expand_work_function = constant_element;
+ if (e->value.constructor
+ && e->value.constructor->expr->expr_type == EXPR_ARRAY
+ && !e->value.constructor->iterator)
+ {
+ /* Expand the constructor. */
+ iter_stack = NULL;
+ expand_save = current_expand;
+ current_expand.expand_work_function = is_constant_element;
- rc = expand_constructor (e->value.constructor);
+ rc = expand_constructor (e->value.constructor);
+
+ current_expand = expand_save;
+ }
+ else
+ {
+ /* No need to expand this further. */
+ for (con = e->value.constructor; con; con = con->next)
+ {
+ if (con->expr->expr_type == EXPR_CONSTANT)
+ continue;
+ else
+ {
+ if (!gfc_is_constant_expr (con->expr))
+ rc = FAILURE;
+ }
+ }
+ }
- current_expand = expand_save;
if (rc == FAILURE)
return 0;