! Copyright (c) 2019, NVIDIA CORPORATION.  All rights reserved.
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
!     http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!

module mod
  implicit none
  integer z
  type t
  integer val
  contains
    procedure, nopass :: foo
    procedure :: bar
  end type
  contains

  integer function foo()
    foo = z
  end function

  subroutine bar(this,i)
    class(t) :: this
    integer :: i
    this%val = i
  end subroutine
  
end module

use mod
integer x
type(t) :: obj
logical rslts(2), expect(2)

expect = .true.

z = 100
call obj%bar(obj%foo())
!print *, obj%val
rslts(1) = obj%val .eq. 100
z = -99

x = obj%foo()
call obj%bar(x)
!print *, obj%val
rslts(2) = obj%val .eq. -99

call check(rslts, expect, 2)
end


