| 1 |
! { dg-do compile } |
| 2 |
! PR fortran/55978 |
| 3 |
! |
| 4 |
! Passing of NULL() with and without MOLD as actual argument |
| 5 |
! |
| 6 |
! Testcase derived from pr55978 comment#16 |
| 7 |
|
| 8 |
program pr55978_c16 |
| 9 |
implicit none |
| 10 |
|
| 11 |
integer, pointer :: p(:) |
| 12 |
integer, allocatable :: a(:) |
| 13 |
character(10), pointer :: c |
| 14 |
character(10), pointer :: cp(:) |
| 15 |
|
| 16 |
type t |
| 17 |
integer, pointer :: p(:) |
| 18 |
integer, allocatable :: a(:) |
| 19 |
end type |
| 20 |
|
| 21 |
type(t) :: d |
| 22 |
|
| 23 |
! (1) pointer |
| 24 |
p => null() |
| 25 |
call sub (p) |
| 26 |
|
| 27 |
! (2) allocatable |
| 28 |
call sub (a) |
| 29 |
call sub (d%a) |
| 30 |
|
| 31 |
! (3) pointer component |
| 32 |
d%p => null () |
| 33 |
call sub (d%p) |
| 34 |
|
| 35 |
! (4) NULL |
| 36 |
call sub (null (a)) ! OK |
| 37 |
call sub (null (p)) ! OK |
| 38 |
call sub (null (d%a)) ! OK |
| 39 |
call sub (null (d%p)) ! OK |
| 40 |
call sub (null ()) ! was erroneously rejected with: |
| 41 |
! Actual argument contains too few elements for dummy argument 'x' (1/4) |
| 42 |
|
| 43 |
call bla (null(c)) |
| 44 |
call bla (null()) ! was erroneously rejected with: |
| 45 |
! Actual argument contains too few elements for dummy argument 'x' (1/10) |
| 46 |
|
| 47 |
call foo (null(cp)) |
| 48 |
call foo (null()) |
| 49 |
|
| 50 |
call bar (null(cp)) |
| 51 |
call bar (null()) ! was erroneously rejected with: |
| 52 |
! Actual argument contains too few elements for dummy argument 'x' (1/70) |
| 53 |
|
| 54 |
contains |
| 55 |
|
| 56 |
subroutine sub(x) |
| 57 |
integer, intent(in), optional :: x(4) |
| 58 |
if (present (x)) stop 1 |
| 59 |
end |
| 60 |
|
| 61 |
subroutine bla(x) |
| 62 |
character(len=10), intent(in), optional :: x |
| 63 |
if (present (x)) stop 2 |
| 64 |
end |
| 65 |
|
| 66 |
subroutine foo(x) |
| 67 |
character(len=10), intent(in), optional :: x(:) |
| 68 |
if (present (x)) stop 3 |
| 69 |
end |
| 70 |
|
| 71 |
subroutine bar(x) |
| 72 |
character(len=10), intent(in), optional :: x(7) |
| 73 |
if (present (x)) stop 4 |
| 74 |
end |
| 75 |
|
| 76 |
end |