summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/size_optional_dim_1.f90
blob: cbf4aa4812ed696917e3b06034002f81397f3c75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
! { dg-do run }
! { dg-additional-options "-fdump-tree-original" }
! PR 30865 - passing a subroutine optional argument to size(dim=...)
! used to segfault.
program main
  implicit none
  integer :: a(2,3)
  integer :: ires

  call checkv (ires, a)
  if (ires /= 6) STOP 1
  call checkv (ires, a, 1)
  if (ires /= 2) STOP 2
contains
  subroutine checkv(ires,a1,opt1)
    integer, intent(out) :: ires
    integer :: a1(:,:)
    integer, optional :: opt1

    ires = size (a1, dim=opt1)
  end subroutine checkv
end program main

! Ensure inline code is generated, cf. PR fortran/94070
! { dg-final { scan-tree-dump-not "_gfortran_size" "original" } }