===================================================================
*************** is_constant_array_expr (gfc_expr *e)
return false;
for (c = e->value.constructor; c; c = c->next)
! if (c->expr->expr_type != EXPR_CONSTANT)
return false;
return true;
return false;
for (c = e->value.constructor; c; c = c->next)
! if (c->expr->expr_type != EXPR_CONSTANT
! && c->expr->expr_type != EXPR_STRUCTURE)
return false;
return true;
*************** gfc_simplify_pack (gfc_expr *array, gfc_
if (array->ts.type == BT_CHARACTER)
result->ts.u.cl = array->ts.u.cl;
+ else if (array->ts.type == BT_DERIVED)
+ result->ts.u.derived = array->ts.u.derived;
return result;
}
*************** inc:
e->ts = source->ts;
e->rank = rank;
+ if (source->ts.type == BT_CHARACTER)
+ e->ts.u.cl = source->ts.u.cl;
+ else if (source->ts.type == BT_DERIVED)
+ e->ts.u.derived = source->ts.u.derived;
+
return e;
}
*************** gfc_simplify_spread (gfc_expr *source, g
if (source->ts.type == BT_CHARACTER)
result->ts.u.cl = source->ts.u.cl;
+ else if (source->ts.type == BT_DERIVED)
+ result->ts.u.derived = source->ts.u.derived;
return result;
}
*************** gfc_simplify_transpose (gfc_expr *matrix
if (matrix->ts.type == BT_CHARACTER)
result->ts.u.cl = matrix->ts.u.cl;
+ else if (matrix->ts.type == BT_DERIVED)
+ result->ts.u.derived = matrix->ts.u.derived;
matrix_rows = mpz_get_si (matrix->shape[0]);
matrix_ctor = matrix->value.constructor;
*************** gfc_simplify_unpack (gfc_expr *vector, g
if (vector->ts.type == BT_CHARACTER)
result->ts.u.cl = vector->ts.u.cl;
+ else if (vector->ts.type == BT_DERIVED)
+ result->ts.u.derived = vector->ts.u.derived;
vector_ctor = vector->value.constructor;
mask_ctor = mask->value.constructor;
===================================================================
***************
+ ! { dg-do compile }
+ ! { dg-options "-fdump-tree-original" }
+ ! Test the fix for PR45081 in which derived type array valued intrinsics failed
+ ! to simplify, which caused an ICE in trans-array.c
+ !
+ ! Contributed by Thorsten Ohl <ohl@physik.uni-wuerzburg.de>
+ !
+ module m
+ implicit none
+ integer :: i
+ type t
+ integer :: i
+ end type t
+ type(t), dimension(4), parameter :: t1 = [( t(i), i = 1, 4)]
+ type(t), dimension(4), parameter :: t2 = [( t(i), i = 8, 11)]
+ type(t), dimension(2,2), parameter :: a = reshape ( t1, [ 2, 2 ] )
+ type(t), dimension(2,2), parameter :: b = transpose (a)
+ type(t), dimension(4), parameter :: c = reshape ( b, [ 4 ] )
+ type(t), dimension(2), parameter :: d = pack ( c, [.false.,.true.,.false.,.true.])
+ type(t), dimension(4), parameter :: e = unpack (d, [.false.,.true.,.false.,.true.], t2)
+ type(t), dimension(4,2), parameter :: f = spread (e, 2, 2)
+ type(t), dimension(8), parameter :: g = reshape ( f, [ 8 ] )
+ integer, parameter :: total = sum(g%i)
+ end module m
+
+ use m
+ integer :: j
+ j = total
+ end
+ ! { dg-final { scan-tree-dump-times "j = 50" 1 "original" } }