1! { dg-do run }
2! PR 30865 - passing a subroutine optional argument to size(dim=...)
3! used to segfault.
4program main
5  implicit none
6  integer :: a(2,3)
7  integer :: ires
8
9  call checkv (ires, a)
10  if (ires /= 6) call abort
11  call checkv (ires, a, 1)
12  if (ires /= 2) call abort
13contains
14  subroutine checkv(ires,a1,opt1)
15    integer, intent(out) :: ires
16    integer :: a1(:,:)
17    integer, optional :: opt1
18
19    ires = size (a1, dim=opt1)
20  end subroutine checkv
21end program main
22