2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / null_1.f90
blobd367bb3de61b741c1bb7b726da147ea55c63c285
1 ! { dg-do compile }
2 ! PR fortran/20858
3 ! If we have "x = null(i)", then "null()" acquires the type, kind type,
4 ! and rank of i and these need to match those of x.
5 program null_1
6 integer, parameter :: sp = kind(1.e0), dp = kind(1.d0)
7 integer, pointer :: i => null()
8 real(sp), pointer :: x => null()
9 real(dp), pointer :: y => null()
10 real(sp), pointer :: z(:) => null()
11 x => null(i) ! { dg-error "types in pointer assignment" }
12 x => null(y) ! { dg-error "types in pointer assignment" }
13 z => null(i) ! { dg-error "types in pointer assignment" }
14 z => null(y) ! { dg-error "types in pointer assignment" }
15 x => null(z) ! { dg-error "ranks in pointer assignment" }
16 z => null(x) ! { dg-error "ranks in pointer assignment" }
17 z => null(z)
18 nullify(i, x, y, z)
19 end program null_1