1 /* Test the fix for PR100911 */
7 #include <ISO_Fortran_binding.h>
9 #define _CFI_type_mask 0xFF
10 #define _CFI_type_kind_shift 8
12 #define _CFI_decode_type(NAME) (signed char)((NAME) & CFI_type_mask)
13 #define _CFI_decode_kind(NAME) (signed char)(((NAME) >> CFI_type_kind_shift) & CFI_type_mask)
15 #define _CFI_encode_type(TYPE, KIND) (int16_t)\
16 ((((KIND) & CFI_type_mask) << CFI_type_kind_shift)\
17 | ((TYPE) & CFI_type_mask))
22 #define CFI_type_Cptr CFI_type_cptr
26 bool c_vrfy_cptr (const CFI_cdesc_t
*restrict
);
28 void check_tk (const CFI_cdesc_t
*restrict
, const CFI_type_t
, const signed char, const size_t, const size_t);
31 c_vrfy_cptr (const CFI_cdesc_t
*restrict auxp
)
33 CFI_index_t i
, lb
, ub
, ex
;
38 assert (auxp
->base_addr
);
39 assert (auxp
->elem_len
>0);
40 lb
= auxp
->dim
[0].lower_bound
;
41 ex
= auxp
->dim
[0].extent
;
43 sz
= (size_t)auxp
->elem_len
/ sizeof (c_ptr
);
46 ip
= (c_ptr
*)auxp
->base_addr
;
47 for (i
=0; i
<ex
; i
++, ip
+=sz
)
48 if ((**ip
) != (int)(i
+1))
50 for (i
=lb
; i
<ub
+1; i
++)
52 ip
= (c_ptr
*)CFI_address(auxp
, &i
);
53 if ((**ip
) != (int)(i
-lb
+1))
60 check_tk (const CFI_cdesc_t
*restrict auxp
, const CFI_type_t type
, const signed char kind
, const size_t elem_len
, const size_t nelem
)
62 signed char ityp
, iknd
;
65 assert (auxp
->elem_len
==elem_len
*nelem
);
66 assert (auxp
->rank
==1);
67 assert (auxp
->dim
[0].sm
>0);
68 assert ((size_t)auxp
->dim
[0].sm
==elem_len
*nelem
);
70 assert (auxp
->type
==type
);
71 ityp
= _CFI_decode_type(auxp
->type
);
72 assert (ityp
== CFI_type_cptr
);
73 iknd
= _CFI_decode_kind(auxp
->type
);
74 assert (_CFI_decode_type(type
)==ityp
);
76 assert (c_vrfy_cptr (auxp
));