1! { dg-do run }
2! Test fix for PR fortran/38823.
3program power
4
5   implicit none
6
7   integer, parameter :: &
8   &  s = kind(1.e0), &
9   &  d = kind(1.d0), &
10   &  e = max(selected_real_kind(precision(1.d0)+1), d)
11
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
18
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
25
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
32
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
36
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
43
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
50
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
57
58end program power
59