2 ! { dg-additional-sources PR94327.c }
4 ! Test the fix for PR94327
9 use, intrinsic :: iso_c_binding
, only
: &
15 integer, parameter :: n
= 11
16 integer, parameter :: u(*) = [(i
, i
=1,n
)]
19 function attr_p_as(a
, s
) result(c
) &
20 bind(c
, name
="get_attr")
21 use, intrinsic :: iso_c_binding
, only
: &
24 integer(kind
=c_int
), pointer, intent(in
) :: a(:)
25 logical(kind
=c_bool
), value
, intent(in
) :: s
26 character(kind
=c_char
) :: c
27 end function attr_p_as
28 function attr_a_as(a
, s
) result(c
) &
29 bind(c
, name
="get_attr")
30 use, intrinsic :: iso_c_binding
, only
: &
33 integer(kind
=c_int
), allocatable
, intent(in
) :: a(:)
34 logical(kind
=c_bool
), value
, intent(in
) :: s
35 character(kind
=c_char
) :: c
36 end function attr_a_as
37 function attr_o_as(a
, s
) result(c
) &
38 bind(c
, name
="get_attr")
39 use, intrinsic :: iso_c_binding
, only
: &
42 integer(kind
=c_int
), intent(in
) :: a(:)
43 logical(kind
=c_bool
), value
, intent(in
) :: s
44 character(kind
=c_char
) :: c
45 end function attr_o_as
46 function attr_p_ar(a
, s
) result(c
) &
47 bind(c
, name
="get_attr")
48 use, intrinsic :: iso_c_binding
, only
: &
51 integer(kind
=c_int
), pointer, intent(in
) :: a(..)
52 logical(kind
=c_bool
), value
, intent(in
) :: s
53 character(kind
=c_char
) :: c
54 end function attr_p_ar
55 function attr_a_ar(a
, s
) result(c
) &
56 bind(c
, name
="get_attr")
57 use, intrinsic :: iso_c_binding
, only
: &
60 integer(kind
=c_int
), allocatable
, intent(in
) :: a(..)
61 logical(kind
=c_bool
), value
, intent(in
) :: s
62 character(kind
=c_char
) :: c
63 end function attr_a_ar
64 function attr_o_ar(a
, s
) result(c
) &
65 bind(c
, name
="get_attr")
66 use, intrinsic :: iso_c_binding
, only
: &
69 integer(kind
=c_int
), intent(in
) :: a(..)
70 logical(kind
=c_bool
), value
, intent(in
) :: s
71 character(kind
=c_char
) :: c
72 end function attr_o_ar
75 integer(kind
=c_int
), target
:: a(n
)
76 integer(kind
=c_int
), allocatable
, target
:: b(:)
77 integer(kind
=c_int
), pointer :: p(:)
78 character(kind
=c_char
) :: c
81 c
= attr_p_as(a
, .true
._c_bool
)
86 c
= attr_p_ar(a
, .true
._c_bool
)
91 c
= attr_o_as(a
, .true
._c_bool
)
96 c
= attr_o_ar(a
, .true
._c_bool
)
100 allocate(b
, source
=u
)
101 c
= attr_p_as(b
, .true
._c_bool
)
103 if(.not
.allocated(b
)) stop 10
104 if(any(b
/=u
)) stop 11
107 allocate(b
, source
=u
)
108 c
= attr_p_ar(b
, .true
._c_bool
)
110 if(.not
.allocated(b
)) stop 13
111 if(any(b
/=u
)) stop 14
114 allocate(b
, source
=u
)
115 c
= attr_a_as(b
, .true
._c_bool
)
117 if(.not
.allocated(b
)) stop 16
118 if(any(b
/=u
)) stop 17
121 allocate(b
, source
=u
)
122 c
= attr_a_ar(b
, .true
._c_bool
)
124 if(.not
.allocated(b
)) stop 19
125 if(any(b
/=u
)) stop 20
128 allocate(b
, source
=u
)
129 c
= attr_o_as(b
, .true
._c_bool
)
131 if(.not
.allocated(b
)) stop 22
132 if(any(b
/=u
)) stop 23
135 allocate(b
, source
=u
)
136 c
= attr_o_ar(b
, .true
._c_bool
)
138 if(.not
.allocated(b
)) stop 25
139 if(any(b
/=u
)) stop 26
142 c
= attr_a_as(b
, .false
._c_bool
)
144 if(allocated(b
)) stop 28
146 c
= attr_a_ar(b
, .false
._c_bool
)
148 if(allocated(b
)) stop 30
152 c
= attr_p_as(p
, .true
._c_bool
)
154 if(.not
.associated(p
)) stop 32
155 if(.not
.associated(p
, a
)) stop 33
156 if(any(p
/=u
)) stop 34
160 c
= attr_p_ar(p
, .true
._c_bool
)
162 if(.not
.associated(p
)) stop 36
163 if(.not
.associated(p
, a
)) stop 37
164 if(any(p
/=u
)) stop 38
168 c
= attr_o_as(p
, .true
._c_bool
)
170 if(.not
.associated(p
)) stop 40
171 if(.not
.associated(p
, a
)) stop 41
172 if(any(p
/=u
)) stop 42
176 c
= attr_o_ar(p
, .true
._c_bool
)
178 if(.not
.associated(p
)) stop 44
179 if(.not
.associated(p
, a
)) stop 45
180 if(any(p
/=u
)) stop 46
183 c
= attr_p_as(p
, .false
._c_bool
)
185 if(associated(p
)) stop 48
186 if(associated(p
, a
)) stop 49
189 c
= attr_p_ar(p
, .false
._c_bool
)
191 if(associated(p
)) stop 51
192 if(associated(p
, a
)) stop 52