2014-07-12 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / warn_conversion.f90
blobe9b7e396e4f098398b3751d7340f118709334418
1 ! { dg-do compile }
2 ! { dg-options "-Wconversion" }
5 ! PR fortran/27866 -improve -Wconversion
7 SUBROUTINE pr27866
8 double precision :: d
9 real :: r
10 d = 4d99
11 r = d ! { dg-warning "conversion" }
12 END SUBROUTINE
14 SUBROUTINE pr27866c4
15 real(kind=4) :: a
16 real(kind=8) :: b
17 integer(kind=1) :: i1
18 integer(kind=4) :: i4
19 i4 = 2.3 ! { dg-warning "conversion" }
20 i1 = 500 ! { dg-error "overflow" }
21 a = 2**26-1 ! assignment INTEGER(4) to REAL(4) - no warning
22 b = 1d999 ! { dg-error "overflow" }
24 a = i4 ! assignment INTEGER(4) to REAL(4) - no warning
25 b = i4 ! assignment INTEGER(4) to REAL(8) - no warning
26 i1 = i4 ! { dg-warning "conversion" }
27 a = b ! { dg-warning "conversion" }
28 END SUBROUTINE
32 ! PR fortran/35003 - spurious warning with -Wconversion
33 ! Contributed by Brian Barnes <bcbarnes AT gmail DOT com>
35 SUBROUTINE pr35003
36 IMPLICIT NONE
37 integer(8) :: i, n
38 n = 1_8
40 do i = 1_8,n
41 enddo
42 END SUBROUTINE
46 ! PR fortran/42809 - Too much noise with -Wconversion
47 ! Contributed by Harald Anlauf <anlauf AT gmx DOT de>
49 SUBROUTINE pr42809
50 implicit none
51 integer, parameter :: sp = kind (1.0)
52 integer, parameter :: dp = kind (1.d0)
53 real(sp) :: s
54 real(dp) :: d
55 complex(dp) :: z
57 s = 0 ! assignment INTEGER(4) to REAL(4) - no warning
58 d = s ! assignment REAL((8)) to REAL(4) - no warning
59 z = (0, 1) ! conversion INTEGER(4) to REAL(4),
60 ! assignment COMPLEX(4) to COMPLEX(8) - no warning
61 END SUBROUTINE