===================================================================
*************** gfc_simplify_xor (gfc_expr *x, gfc_expr
gfc_expr *
gfc_convert_constant (gfc_expr *e, bt type, int kind)
{
! gfc_expr *g, *result, *(*f) (gfc_expr *, int);
! gfc_constructor *c;
switch (e->ts.type)
{
gfc_expr *
gfc_convert_constant (gfc_expr *e, bt type, int kind)
{
! gfc_expr *result, *(*f) (gfc_expr *, int);
! gfc_constructor *c, *t;
switch (e->ts.type)
{
*************** gfc_convert_constant (gfc_expr *e, bt ty
gfc_expr *tmp;
if (c->iterator == NULL)
{
tmp = f (c->expr, kind);
! if (tmp == NULL)
{
gfc_free_expr (result);
return NULL;
}
! gfc_constructor_append_expr (&result->value.constructor,
tmp, &c->where);
! }
! else
! {
! gfc_constructor *n;
! g = gfc_convert_constant (c->expr, type, kind);
! if (g == NULL || g == &gfc_bad_expr)
! {
! gfc_free_expr (result);
! return g;
! }
! n = gfc_constructor_get ();
! n->expr = g;
! n->iterator = gfc_copy_iterator (c->iterator);
! n->where = c->where;
! gfc_constructor_append (&result->value.constructor, n);
! }
}
break;
gfc_expr *tmp;
if (c->iterator == NULL)
{
+ if (c->expr->expr_type == EXPR_ARRAY)
+ tmp = gfc_convert_constant (c->expr, type, kind);
+ else
tmp = f (c->expr, kind);
! }
! else
! tmp = gfc_convert_constant (c->expr, type, kind);
!
! if (tmp == NULL || tmp == &gfc_bad_expr)
{
gfc_free_expr (result);
return NULL;
}
! t = gfc_constructor_append_expr (&result->value.constructor,
tmp, &c->where);
! if (c->iterator)
! t->iterator = gfc_copy_iterator (c->iterator);
}
break;
===================================================================
***************
! handled correctly.
program test
implicit none
! integer, parameter :: n = 2**16
real, dimension(n) :: y
integer :: i
! y = (/ (1, i=1, n) /)
! if (y(2) /= 1) stop 1
end program test
! handled correctly.
program test
implicit none
! integer, parameter :: n = 2**16 + 1
real, dimension(n) :: y
+ real, dimension(2*n) :: z
integer :: i
!
! y = [(1, i=1, n) ] ! This was the original problem
! if (int(y(2)) /= 1) stop 1
!
! y = [33, (1, i=1, n-1) ] ! Check that something more complicated works
! if (int(y(3)) /= 1) stop 2
!
! z = [[(1, i=1, n) ],[(2, i=1, n) ]] ! Failed with first version of the fix
!
! if (int(z(2)) /= 1) stop 3
! if (int(z(n+1)) /= 2) stop 4
end program test