@@ -6,6 +6,17 @@ module reduce_mod
66 integer :: a
77end type
88
9+ abstract interface
10+ pure function red_int1_interface (a , b )
11+ integer (1 ), intent (in ) :: a, b
12+ integer (1 ) :: red_int1_interface
13+ end function
14+ pure function red_int1_interface_value (a , b )
15+ integer (1 ), value, intent (in ) :: a, b
16+ integer (1 ) :: red_int1_interface_value
17+ end function
18+ end interface
19+
920contains
1021
1122pure function red_int1 (a ,b )
@@ -20,9 +31,13 @@ pure function red_int1_value(a,b)
2031 red_int1_value = a + b
2132end function
2233
23- subroutine integer1 (a , id )
34+ subroutine integer1 (a , id , d1 , d2 )
2435 integer (1 ), intent (in ) :: a(:)
2536 integer (1 ) :: res, id
37+ procedure (red_int1_interface), pointer :: fptr
38+ procedure (red_int1_interface_value), pointer :: fptr_value
39+ procedure (red_int1_interface) :: d1
40+ procedure (red_int1_interface_value) :: d2
2641
2742 res = reduce(a, red_int1)
2843
@@ -33,10 +48,19 @@ subroutine integer1(a, id)
3348 res = reduce(a, red_int1, [.true. , .true. , .false. ])
3449
3550 res = reduce(a, red_int1_value)
51+
52+ fptr = > red_int1
53+ res = reduce(a, fptr)
54+
55+ fptr_value = > red_int1_value
56+ res = reduce(a, fptr_value)
57+
58+ ! res = reduce(a, d1)
59+ ! res = reduce(a, d2)
3660end subroutine
3761
3862! CHECK-LABEL: func.func @_QMreduce_modPinteger1(
39- ! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi8>> {fir.bindc_name = "a"}, %[[ARG1:.*]]: !fir.ref<i8> {fir.bindc_name = "id"})
63+ ! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xi8>> {fir.bindc_name = "a"}, %[[ARG1:.*]]: !fir.ref<i8> {fir.bindc_name = "id"}
4064! CHECK: %[[A:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QMreduce_modFinteger1Ea"} : (!fir.box<!fir.array<?xi8>>, !fir.dscope) -> (!fir.box<!fir.array<?xi8>>, !fir.box<!fir.array<?xi8>>)
4165! CHECK: %[[ID:.*]]:2 = hlfir.declare %[[ARG1]] dummy_scope %{{.*}} {uniq_name = "_QMreduce_modFinteger1Eid"} : (!fir.ref<i8>, !fir.dscope) -> (!fir.ref<i8>, !fir.ref<i8>)
4266! CHECK: %[[ALLOC_RES:.*]] = fir.alloca i8 {bindc_name = "res", uniq_name = "_QMreduce_modFinteger1Eres"}
@@ -64,6 +88,10 @@ subroutine integer1(a, id)
6488! CHECK: %[[CONV_MASK:.*]] = fir.convert %[[BOXED_MASK]] : (!fir.box<!fir.array<3x!fir.logical<4>>>) -> !fir.box<none>
6589! CHECK: fir.call @_FortranAReduceInteger1Ref(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %[[CONV_MASK]], %{{.*}}, %false{{.*}})
6690! CHECK: fir.call @_FortranAReduceInteger1Value
91+ ! CHECK: fir.call @_FortranAReduceInteger1Ref
92+ ! CHECK: fir.call @_FortranAReduceInteger1Value
93+ ! TODO fir.call @_FortranAReduceInteger1Ref
94+ ! TODO fir.call @_FortranAReduceInteger1Value
6795
6896pure function red_int2 (a ,b )
6997 integer (2 ), intent (in ) :: a, b
0 commit comments