{
gfc_expr *result, *a, *b, *c;
- /* Set result to an INTEGER(1) 0 for numeric types and .false. for
+ /* Set result to an INTEGER(1) 0 for numeric types and .false. for
LOGICAL. Mixed-mode math in the loop will promote result to the
correct type and kind. */
if (matrix_a->ts.type == BT_LOGICAL)
}
else
shiftvec = NULL;
-
+
/* Shut up compiler */
len = 1;
rsoffset = 1;
gfc_expr*
gfc_simplify_dot_product (gfc_expr *vector_a, gfc_expr *vector_b)
{
- /* If vector_a is a zero-sized array, the result is 0 for INTEGER,
+ /* If vector_a is a zero-sized array, the result is 0 for INTEGER,
REAL, and COMPLEX types and .false. for LOGICAL. */
if (vector_a->shape && mpz_get_si (vector_a->shape[0]) == 0)
{
{
if (boundary->rank > 0)
gfc_simplify_expr (boundary, 1);
-
+
if (!gfc_is_constant_expr (boundary))
return NULL;
}
temp_boundary = true;
switch (array->ts.type)
{
-
+
case BT_INTEGER:
bnd = gfc_get_int_expr (array->ts.kind, NULL, 0);
break;
temp_boundary = false;
bnd = boundary;
}
-
+
gfc_array_size (array, &size);
arraysize = mpz_get_ui (size);
mpz_clear (size);
if (bnd_ctor)
bnd_ctor = gfc_constructor_next (bnd_ctor);
-
+
count[0]++;
n = 0;
while (count[n] == extent[n])
if (*src && min_max_choose (*src, ex, sign) > 0)
mpz_set_si ((*dest)->value.integer, n + 1);
}
-
+
count[0]++;
base += sstride[0];
dest += dstride[0];
gfc_expr *extremum;
int ikind;
int init_val;
-
+
if (!is_constant_array_expr (array)
|| !gfc_is_constant_expr (dim))
return NULL;
gfc_expr *
gfc_convert_constant (gfc_expr *e, bt type, int kind)
{
- gfc_expr *g, *result, *(*f) (gfc_expr *, int);
- gfc_constructor *c;
+ gfc_expr *result, *(*f) (gfc_expr *, int);
+ gfc_constructor *c, *t;
switch (e->ts.type)
{
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);
+ 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_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);
+ 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;
--- /dev/null
+! { dg-do run }
+! PR 84931 - long array constructors with type conversion were not
+! handled correctly. array_constructor_52.f90 tests the original
+! problem.
+program test
+ implicit none
+ integer, parameter :: n = 2**16 + 1
+ real, dimension(n) :: y
+ real, dimension(2*n) :: z
+ integer :: i
+
+ y = [33, (1, i=1, n-1) ] ! Check that something more complicated works
+ if (int(y(3)) /= 1) stop 1
+
+ z = [[(1, i=1, n) ],[(2, i=1, n) ]] ! Failed with first version of the fix
+
+ if (int(z(2)) /= 1) stop 2
+ if (int(z(n+1)) /= 2) stop 3
+end program test