mirror of git://gcc.gnu.org/git/gcc.git
re PR fortran/84931 (Expansion of array constructor with constant implied-do-object goes sideways)
2018-03-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/84931 * simplify.c (gfc_convert_constant): Handle case of array constructors within an array that has no iterator and improve the conciseness of this section of code. 2018-03-30 Paul Thomas <pault@gcc.gnu.org> PR fortran/84931 * gfortran.dg/array_constructor_53.f90: New test. From-SVN: r258977
This commit is contained in:
parent
13b5a6bf00
commit
0ada0dc0c6
|
|
@ -1,3 +1,10 @@
|
|||
2018-03-30 Paul Thomas <pault@gcc.gnu.org>
|
||||
|
||||
PR fortran/84931
|
||||
* simplify.c (gfc_convert_constant): Handle case of array
|
||||
constructors within an array that has no iterator and improve
|
||||
the conciseness of this section of code.
|
||||
|
||||
2017-03-30 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/85111
|
||||
|
|
|
|||
|
|
@ -7879,8 +7879,8 @@ gfc_simplify_xor (gfc_expr *x, gfc_expr *y)
|
|||
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)
|
||||
{
|
||||
|
|
@ -8017,31 +8017,24 @@ gfc_convert_constant (gfc_expr *e, bt type, int kind)
|
|||
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);
|
||||
if (tmp == NULL)
|
||||
}
|
||||
else
|
||||
tmp = gfc_convert_constant (c->expr, type, kind);
|
||||
|
||||
if (tmp == NULL || tmp == &gfc_bad_expr)
|
||||
{
|
||||
gfc_free_expr (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gfc_constructor_append_expr (&result->value.constructor,
|
||||
t = 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);
|
||||
}
|
||||
if (c->iterator)
|
||||
t->iterator = gfc_copy_iterator (c->iterator);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
2018-03-30 Paul Thomas <pault@gcc.gnu.org>
|
||||
|
||||
PR fortran/84931
|
||||
* gfortran.dg/array_constructor_53.f90: New test.
|
||||
|
||||
2018-03-30 Thomas Koenig <tkoenig@gcc.gnu.org>
|
||||
|
||||
PR fortran/85130
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
! { 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
|
||||
Loading…
Reference in New Issue