1! { dg-do compile }
2!
3! PR 36947: Attributes not fully checked comparing actual vs dummy procedure
4!
5! Original test case by Walter Spector <w6ws@earthlink.net>
6! Modified by Janus Weil <janus@gcc.gnu.org>
7
8module testsub
9  contains
10  subroutine test(sub)
11    interface
12      subroutine sub(x)
13        integer, intent(in), optional:: x
14      end subroutine
15    end interface
16    call sub()
17  end subroutine
18end module
19
20module sub
21  contains
22  subroutine subActual(x)
23    ! actual subroutine's argment is different in intent
24    integer, intent(inout),optional:: x
25  end subroutine
26  subroutine subActual2(x)
27    ! actual subroutine's argment is missing OPTIONAL
28    integer, intent(in):: x
29  end subroutine
30end module
31
32program interfaceCheck
33  use testsub
34  use sub
35
36  integer :: a
37
38  call test(subActual)  ! { dg-error "INTENT mismatch in argument" }
39  call test(subActual2)  ! { dg-error "OPTIONAL mismatch in argument" }
40end program
41