OSDN Git Service

PR c++/9335
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / array_constructor_23.f
1 ! { dg-do run }
2 ! { dg-require-effective-target fortran_large_real }
3 ! Tests the fix for PR35944/6/7, in which the variable array constructors below
4 ! were incorrectly translated and wrong code was produced.
5 !
6 ! Contributed by Dick Hendrickson <dick.hendrickson@gmail.com>
7 !
8       program try_fa6013
9       call fa6013 (10, 1, -1)
10       call fa6077 (10, 1, -1, (/1,2,3,4,5,6,7,8,9,10/))
11       call fa2083
12       end program
13
14       subroutine  FA6013 (nf10, nf1, mf1)
15       integer, parameter :: kv = 4
16       REAL(KV) DDA1(10)
17       REAL(KV) DDA2(10)
18       REAL(KV) DDA(10), dval
19       dda = (/1,2,3,4,5,6,7,8,9,10/)
20       DDA1 = ATAN2 ((/(REAL(J1,KV),J1=1,10)/),
21      $                 REAL((/(J1,J1=nf10,nf1,mf1)/), KV))   !fails
22       DDA2 = ATAN2 (DDA, DDA(10:1:-1))
23       if (any (DDA1 .ne. DDA2)) call abort ()
24       END
25
26       subroutine FA6077 (nf10,nf1,mf1, ida)
27       INTEGER IDA1(10)
28       INTEGER IDA2(10), ida(10)
29       IDA1 = IEOR((/1,2,3,4,5,6,7,8,9,10/),
30      $            (/(IDA(J1),J1=10,1,-1)/) )
31       IDA2 = IEOR ((/1,2,3,4,5,6,7,8,9,10/), (/10,9,8,7,6,5,4,3,2,1/) )
32       if (any (ida1 .ne. ida2)) call abort ()
33       END SUBROUTINE
34
35       subroutine fa2083
36       implicit none
37       integer j1,k
38       parameter (k=selected_real_kind (precision (0.0_8) + 1)) ! failed
39       REAL(k) QDA1(10)
40       REAL(k) QDA(10), qval
41       qda = (/ 1,2,3,4,5,6,7,8,9,10 /)
42       QDA1 = MOD ( 1.1_k*( QDA(1) -5.0_k), P=( QDA -2.5_k))
43       DO J1 = 1,10
44         QVAL = MOD(1.1_k*(QDA(1)-5.0_k),P=(QDA(J1)-2.5_k))
45         if (qval .ne. qda1(j1)) call abort ()
46       ENDDO
47       END
48