2 ! Check the fix for PR20893, in which actual arguments could violate:
3 ! "(5) If it is an array, it shall not be supplied as an actual argument to
4 ! an elemental procedure unless an array of the same rank is supplied as an
5 ! actual argument corresponding to a nonoptional dummy argument of that
6 ! elemental procedure." (12.4.1.5)
8 ! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
12 SUBROUTINE T1(A1,A2,A3)
13 INTEGER :: A1,A2, A4(2)
14 INTEGER, OPTIONAL :: A3(2)
16 elemental function efoo (B1,B2,B3) result(bar)
17 INTEGER, intent(in) :: B1, B2
19 INTEGER, OPTIONAL, intent(in) :: B3
23 ! check an intrinsic function
24 write(6,*) MAX(A1,A2,A3) ! { dg-error "array and OPTIONAL" }
25 write(6,*) MAX(A1,A3,A2)
26 write(6,*) MAX(A1,A4,A3)
27 ! check an internal elemental function
28 write(6,*) foo(A1,A2,A3) ! { dg-error "array and OPTIONAL" }
29 write(6,*) foo(A1,A3,A2)
30 write(6,*) foo(A1,A4,A3)
31 ! check an external elemental function
32 write(6,*) efoo(A1,A2,A3) ! { dg-error "array and OPTIONAL" }
33 write(6,*) efoo(A1,A3,A2)
34 write(6,*) efoo(A1,A4,A3)
35 ! check an elemental subroutine
36 call foobar (A1,A2,A3) ! { dg-error "array and OPTIONAL" }
37 call foobar (A1,A2,A4)
38 call foobar (A1,A4,A4)
40 elemental function foo (B1,B2,B3) result(bar)
41 INTEGER, intent(in) :: B1, B2
43 INTEGER, OPTIONAL, intent(in) :: B3
46 elemental subroutine foobar (B1,B2,B3)
47 INTEGER, intent(OUT) :: B1
48 INTEGER, optional, intent(in) :: B2, B3