2 ! { dg-options "-Wpedantic" }
6 ! Check that the nonabsent arrary is used for scalarization:
7 ! Either the NONOPTIONAL one or, if there are none, any array.
9 ! Based on a program by Daniel C Chen
13 integer :: arr1(2), arr2(2)
20 subroutine sub1 (arg1
, arg2
)
21 integer, optional
:: arg1(:)
23 ! print *, fun1 (arg1, arg2)
24 if (size (fun1 (arg1
, arg2
)) /= 2) STOP 1
25 if (any (fun1 (arg1
, arg2
) /= [1,2])) STOP 2
28 elemental
function fun1 (arg1
, arg2
)
29 integer,intent(in
), optional
:: arg1
30 integer,intent(in
) :: arg2
38 integer :: arr1(2), arr2(2)
41 call sub2 (arr1
, arg2
=arr2
)
43 subroutine sub2 (arg1
, arg2
)
44 integer, optional
:: arg1(:)
45 integer, optional
:: arg2(:)
46 ! print *, fun2 (arg1, arg2)
47 if (size (fun2 (arg1
, arg2
)) /= 2) STOP 3 ! { dg-warning "is an array and OPTIONAL" }
48 if (any (fun2 (arg1
, arg2
) /= [1,2])) STOP 4 ! { dg-warning "is an array and OPTIONAL" }
51 elemental
function fun2 (arg1
,arg2
)
52 integer,intent(in
), optional
:: arg1
53 integer,intent(in
), optional
:: arg2