aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/typebound_call_13.f03
blob: db220787e55f62c9100d91511f38cfe57aaa3342 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
! { dg-do run }
!
! PR 43256: [OOP] TBP with missing optional arg
!
! Contributed by Janus Weil

module module_myobj

  implicit none

  type :: myobj
  contains
    procedure, nopass :: myfunc
  end type

contains

  integer function myfunc(status)
    integer, optional :: status
    if (present(status)) then
      myfunc = 1
    else
      myfunc = 2
    end if
  end function

end module


program test_optional

  use :: module_myobj
  implicit none

  integer     :: res = 0
  type(myobj) :: myinstance

  res = myinstance%myfunc()
  if (res /= 2) call abort()

end program