5 ! Check that the nonabsent arrary is used for scalarization:
6 ! Either the NONOPTIONAL one or, if there are none, any array.
8 ! Based on a program by Daniel C Chen
12 integer :: arr1(2), arr2(2)
19 subroutine sub1 (arg1
, arg2
)
20 integer, optional
:: arg1(:)
22 ! print *, fun1 (arg1, arg2)
23 if (size (fun1 (arg1
, arg2
)) /= 2) call abort() ! { dg-warning "is an array and OPTIONAL" }
24 if (any (fun1 (arg1
, arg2
) /= [1,2])) call abort() ! { dg-warning "is an array and OPTIONAL" }
27 elemental
function fun1 (arg1
, arg2
)
28 integer,intent(in
), optional
:: arg1
29 integer,intent(in
) :: arg2
37 integer :: arr1(2), arr2(2)
40 call sub2 (arr1
, arg2
=arr2
)
42 subroutine sub2 (arg1
, arg2
)
43 integer, optional
:: arg1(:)
44 integer, optional
:: arg2(:)
45 ! print *, fun2 (arg1, arg2)
46 if (size (fun2 (arg1
, arg2
)) /= 2) call abort() ! { dg-warning "is an array and OPTIONAL" }
47 if (any (fun2 (arg1
, arg2
) /= [1,2])) call abort() ! { dg-warning "is an array and OPTIONAL" }
50 elemental
function fun2 (arg1
,arg2
)
51 integer,intent(in
), optional
:: arg1
52 integer,intent(in
), optional
:: arg2