fix pr/45972
[official-gcc.git] / gcc / testsuite / gfortran.dg / array_constructor_23.f
blobfa0a28a1f1782e058d6bbedc6fc01ff116c2b4b6
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.
6 ! Contributed by Dick Hendrickson <dick.hendrickson@gmail.com>
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
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 - DDA2 .gt. epsilon(dval))) call abort ()
24 END
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
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 - qda1(j1) .gt. epsilon(qval)) call abort ()
46 ENDDO
47 END