2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / power1.f90
blob50dbac2756dcc5e40155bff105eb54ee04eb83cb
1 ! { dg-do run }
2 ! Test fix for PR fortran/38823.
3 program power
5 implicit none
7 integer, parameter :: &
8 & s = kind(1.e0), &
9 & d = kind(1.d0), &
10 & e = max(selected_real_kind(precision(1.d0)+1), d)
12 real(s), parameter :: ris = 2.e0_s**2
13 real(d), parameter :: rid = 2.e0_d**2
14 real(e), parameter :: rie = 2.e0_e**2
15 complex(s), parameter :: cis = (2.e0_s,1.e0_s)**2
16 complex(d), parameter :: cid = (2.e0_d,1.e0_d)**2
17 complex(e), parameter :: cie = (2.e0_e,1.e0_e)**2
19 real(s), parameter :: rrs = 2.e0_s**2.e0
20 real(d), parameter :: rrd = 2.e0_d**2.e0
21 real(e), parameter :: rre = 2.e0_e**2.e0
22 complex(s), parameter :: crs = (2.e0_s,1.e0_s)**2.e0
23 complex(d), parameter :: crd = (2.e0_d,1.e0_d)**2.e0
24 complex(e), parameter :: cre = (2.e0_e,1.e0_e)**2.e0
26 real(s), parameter :: rds = 2.e0_s**2.e0_d
27 real(d), parameter :: rdd = 2.e0_d**2.e0_d
28 real(e), parameter :: rde = 2.e0_e**2.e0_d
29 complex(s), parameter :: cds = (2.e0_s,1.e0_s)**2.e0_d
30 complex(d), parameter :: cdd = (2.e0_d,1.e0_d)**2.e0_d
31 complex(e), parameter :: cde = (2.e0_e,1.e0_e)**2.e0_d
33 real(s), parameter :: eps_s = 1.e-5_s
34 real(d), parameter :: eps_d = 1.e-10_d
35 real(e), parameter :: eps_e = 1.e-10_e
37 if (abs(ris - 4) > eps_s) call abort
38 if (abs(rid - 4) > eps_d) call abort
39 if (abs(rie - 4) > eps_e) call abort
40 if (abs(real(cis, s) - 3) > eps_s .or. abs(aimag(cis) - 4) > eps_s) call abort
41 if (abs(real(cid, d) - 3) > eps_d .or. abs(aimag(cid) - 4) > eps_d) call abort
42 if (abs(real(cie, e) - 3) > eps_e .or. abs(aimag(cie) - 4) > eps_e) call abort
44 if (abs(rrs - 4) > eps_s) call abort
45 if (abs(rrd - 4) > eps_d) call abort
46 if (abs(rre - 4) > eps_e) call abort
47 if (abs(real(crs, s) - 3) > eps_s .or. abs(aimag(crs) - 4) > eps_s) call abort
48 if (abs(real(crd, d) - 3) > eps_d .or. abs(aimag(crd) - 4) > eps_d) call abort
49 if (abs(real(cre, e) - 3) > eps_e .or. abs(aimag(cre) - 4) > eps_e) call abort
51 if (abs(rds - 4) > eps_s) call abort
52 if (abs(rdd - 4) > eps_d) call abort
53 if (abs(rde - 4) > eps_e) call abort
54 if (abs(real(cds, s) - 3) > eps_s .or. abs(aimag(cds) - 4) > eps_s) call abort
55 if (abs(real(cdd, d) - 3) > eps_d .or. abs(aimag(cdd) - 4) > eps_d) call abort
56 if (abs(real(cde, e) - 3) > eps_e .or. abs(aimag(cde) - 4) > eps_e) call abort
58 end program power