1! { dg-do run }
2! { dg-options "-ffrontend-optimize -fdump-tree-original" }
3! Test that reduction optimization doesn't break with a function expression
4! in an array constructor.
5program main
6  implicit none
7  integer, parameter :: dp=selected_real_kind(15)
8  real(kind=dp), dimension(2,2) :: a
9  real(kind=dp) thirteen
10
11  data a /2._dp,3._dp,5._dp,7._dp/
12  thirteen = 13._dp
13  if (abs (product([[sum([eleven_ones()]), thirteen], a]) - 30030._dp) > 1e-8) call abort
14 contains
15  function eleven_ones()
16    real(kind=dp) :: eleven_ones(11)
17    integer       :: i
18
19    eleven_ones = [ (1._dp, i=1,11) ]
20  end function eleven_ones
21end program main
22! { dg-final { scan-tree-dump-times "while" 4 "original" } }
23! { dg-final { cleanup-tree-dump "original" } }
24
25