| 1 |
! { dg-options "-fno-range-check" } |
| 2 |
! { dg-add-options ieee } |
| 3 |
module mod_check |
| 4 |
implicit none |
| 5 |
|
| 6 |
interface check |
| 7 |
module procedure check_i8 |
| 8 |
module procedure check_i4 |
| 9 |
module procedure check_r8 |
| 10 |
module procedure check_r4 |
| 11 |
module procedure check_c8 |
| 12 |
module procedure check_c4 |
| 13 |
end interface check |
| 14 |
|
| 15 |
contains |
| 16 |
|
| 17 |
subroutine check_i8 (a, b) |
| 18 |
integer(kind=8), intent(in) :: a, b |
| 19 |
if (a /= b) STOP 1 |
| 20 |
end subroutine check_i8 |
| 21 |
|
| 22 |
subroutine check_i4 (a, b) |
| 23 |
integer(kind=4), intent(in) :: a, b |
| 24 |
if (a /= b) STOP 2 |
| 25 |
end subroutine check_i4 |
| 26 |
|
| 27 |
subroutine check_r8 (a, b) |
| 28 |
real(kind=8), intent(in) :: a, b |
| 29 |
if (a /= b) STOP 3 |
| 30 |
end subroutine check_r8 |
| 31 |
|
| 32 |
subroutine check_r4 (a, b) |
| 33 |
real(kind=4), intent(in) :: a, b |
| 34 |
if (a /= b) STOP 4 |
| 35 |
end subroutine check_r4 |
| 36 |
|
| 37 |
subroutine check_c8 (a, b) |
| 38 |
complex(kind=8), intent(in) :: a, b |
| 39 |
if (a /= b) STOP 5 |
| 40 |
end subroutine check_c8 |
| 41 |
|
| 42 |
subroutine check_c4 (a, b) |
| 43 |
complex(kind=4), intent(in) :: a, b |
| 44 |
if (a /= b) STOP 6 |
| 45 |
end subroutine check_c4 |
| 46 |
|
| 47 |
end module mod_check |
| 48 |
|
| 49 |
program test |
| 50 |
use mod_check |
| 51 |
implicit none |
| 52 |
|
| 53 |
integer(kind=4) :: i4 |
| 54 |
integer(kind=8) :: i8 |
| 55 |
real(kind=4) :: r4 |
| 56 |
real(kind=8) :: r8 |
| 57 |
complex(kind=4) :: c4 |
| 58 |
complex(kind=8) :: c8 |
| 59 |
|
| 60 |
#define TEST(base,exp,var) var = base; call check((var)**(exp),(base)**(exp)) |
| 61 |
|
| 62 |
!!!!! INTEGER BASE !!!!! |
| 63 |
TEST(3,23,i4) |
| 64 |
TEST(-3,23,i4) |
| 65 |
TEST(3_8,43_8,i8) |
| 66 |
TEST(-3_8,43_8,i8) |
| 67 |
|
| 68 |
!!!!! REAL BASE !!!!! |
| 69 |
TEST(0.0,-1,r4) |
| 70 |
TEST(0.0,-huge(0)-1,r4) |
| 71 |
TEST(2.0,huge(0),r4) |
| 72 |
TEST(nearest(1.0,-1.0),-huge(0),r4) |
| 73 |
|
| 74 |
end program test |