1 /* Test the fix for PR100906 */
7 /* #include <uchar.h> */
9 #include <ISO_Fortran_binding.h>
11 #define _CFI_type_mask 0xFF
12 #define _CFI_type_kind_shift 8
14 #define _CFI_decode_type(NAME) (signed char)((NAME) & CFI_type_mask)
15 #define _CFI_decode_kind(NAME) (signed char)(((NAME) >> CFI_type_kind_shift) & CFI_type_mask)
17 #define _CFI_encode_type(TYPE, KIND) (int16_t)\
18 ((((KIND) & CFI_type_mask) << CFI_type_kind_shift)\
19 | ((TYPE) & CFI_type_mask))
25 /* typedef char32_t c_ucs4_char; */
26 typedef uint32_t char32_t
;
27 typedef uint32_t c_ucs4_char
;
29 bool charcmp (char *, char, size_t);
31 bool ucharcmp (char32_t
*, char32_t
, size_t);
33 bool c_vrfy_c_char (const CFI_cdesc_t
*restrict
, const size_t);
35 bool c_vrfy_c_ucs4_char (const CFI_cdesc_t
*restrict
, const size_t);
37 bool c_vrfy_character (const CFI_cdesc_t
*restrict
, const size_t);
39 void check_tk (const CFI_cdesc_t
*restrict
, const CFI_type_t
, const signed char, const size_t, const size_t);
42 charcmp (char *c
, char v
, size_t n
)
48 for (i
=0; ((i
<n
)&&(res
)); i
++, c
++)
54 ucharcmp (char32_t
*c
, char32_t v
, size_t n
)
57 char32_t b
= (char32_t
)0xFF01;
60 for (i
=0; ((i
<n
)&&(res
)); i
++, c
++)
66 c_vrfy_c_char (const CFI_cdesc_t
*restrict auxp
, const size_t len
)
68 CFI_index_t i
, lb
, ub
, ex
;
73 assert (auxp
->base_addr
);
74 assert (auxp
->elem_len
>0);
75 lb
= auxp
->dim
[0].lower_bound
;
76 ex
= auxp
->dim
[0].extent
;
78 sz
= (size_t)auxp
->elem_len
/ sizeof (c_char
);
81 ip
= (c_char
*)auxp
->base_addr
;
82 for (i
=0; i
<ex
; i
++, ip
+=sz
)
83 if (!charcmp (ip
, (c_char
)(i
), sz
))
85 for (i
=lb
; i
<ub
+1; i
++)
87 ip
= (c_char
*)CFI_address(auxp
, &i
);
88 if (!charcmp (ip
, (c_char
)(i
-lb
), sz
))
95 c_vrfy_c_ucs4_char (const CFI_cdesc_t
*restrict auxp
, const size_t len
)
97 CFI_index_t i
, lb
, ub
, ex
;
99 c_ucs4_char
*ip
= NULL
;
102 assert (auxp
->base_addr
);
103 assert (auxp
->elem_len
>0);
104 lb
= auxp
->dim
[0].lower_bound
;
105 ex
= auxp
->dim
[0].extent
;
107 sz
= (size_t)auxp
->elem_len
/ sizeof (c_ucs4_char
);
110 ip
= (c_ucs4_char
*)auxp
->base_addr
;
111 for (i
=0; i
<ex
; i
++, ip
+=sz
)
112 if (!ucharcmp (ip
, (c_ucs4_char
)(i
), sz
))
114 for (i
=lb
; i
<ub
+1; i
++)
116 ip
= (c_ucs4_char
*)CFI_address(auxp
, &i
);
117 if (!ucharcmp (ip
, (c_ucs4_char
)(i
-lb
), sz
))
124 c_vrfy_character (const CFI_cdesc_t
*restrict auxp
, const size_t len
)
126 signed char type
, kind
;
129 type
= _CFI_decode_type(auxp
->type
);
130 kind
= _CFI_decode_kind(auxp
->type
);
131 assert (type
== CFI_type_Character
);
135 return c_vrfy_c_char (auxp
, len
);
138 return c_vrfy_c_ucs4_char (auxp
, len
);
147 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
)
149 signed char ityp
, iknd
;
152 assert (auxp
->elem_len
==elem_len
*nelem
);
153 assert (auxp
->rank
==1);
154 assert (auxp
->dim
[0].sm
>0);
155 assert ((size_t)auxp
->dim
[0].sm
==elem_len
*nelem
);
157 assert (auxp
->type
==type
);
158 ityp
= _CFI_decode_type(auxp
->type
);
159 assert (ityp
== CFI_type_Character
);
160 iknd
= _CFI_decode_kind(auxp
->type
);
161 assert (_CFI_decode_type(type
)==ityp
);
163 assert (c_vrfy_character (auxp
, nelem
));