1 /* Test the fix for PR100914 */
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))
22 #define CMPLXF(x, y) ((float complex)((float)(x) + I * (float)(y)))
25 #define CMPLX(x, y) ((double complex)((double)(x) + (double complex)I * (double)(y)))
28 #define CMPLXL(x, y) ((long double complex)((long double)(x) + (long double complex)I * (long double)(y)))
31 #define CMPLX(x, y) ((_Float128 _Complex )((double)(x) + (double complex)I * (double)(y)))
36 typedef float _Complex c_float_complex
;
37 typedef double _Complex c_double_complex
;
38 typedef long double _Complex c_long_double_complex
;
39 typedef _Float128 _Complex c_float128_complex
;
41 bool c_vrfy_c_float_complex (const CFI_cdesc_t
*restrict
);
43 bool c_vrfy_c_double_complex (const CFI_cdesc_t
*restrict
);
45 bool c_vrfy_c_long_double_complex (const CFI_cdesc_t
*restrict
);
47 bool c_vrfy_c_float128_complex (const CFI_cdesc_t
*restrict
);
49 bool c_vrfy_complex (const CFI_cdesc_t
*restrict
);
51 bool c_vrfy_desc (const CFI_cdesc_t
*restrict
, const CFI_type_t
, const signed char, const size_t, const size_t);
53 void check_tk (const CFI_cdesc_t
*restrict
, const CFI_type_t
, const signed char, const size_t, const size_t);
58 c_vrfy_c_float_complex (const CFI_cdesc_t
*restrict auxp
)
60 CFI_index_t i
, lb
, ub
, ex
;
62 c_float_complex
*ip
= NULL
;
65 assert (auxp
->base_addr
);
66 assert (auxp
->elem_len
>0);
67 lb
= auxp
->dim
[0].lower_bound
;
68 ex
= auxp
->dim
[0].extent
;
70 sz
= (size_t)auxp
->elem_len
/ sizeof (c_float_complex
);
73 ip
= (c_float_complex
*)auxp
->base_addr
;
74 for (i
=0; i
<ex
; i
++, ip
+=sz
)
75 if ((cabsf (*ip
-(c_float_complex
)(CMPLXF((i
+1), (2*(i
+1)))))>(float)0.0))
77 for (i
=lb
; i
<ub
+1; i
++)
79 ip
= (c_float_complex
*)CFI_address(auxp
, &i
);
80 if ((cabsf (*ip
-(c_float_complex
)(CMPLXF((i
-lb
+1), (2*(i
-lb
+1)))))>(float)0.0))
87 c_vrfy_c_double_complex (const CFI_cdesc_t
*restrict auxp
)
89 CFI_index_t i
, lb
, ub
, ex
;
91 c_double_complex
*ip
= NULL
;
94 assert (auxp
->base_addr
);
95 assert (auxp
->elem_len
>0);
96 lb
= auxp
->dim
[0].lower_bound
;
97 ex
= auxp
->dim
[0].extent
;
99 sz
= (size_t)auxp
->elem_len
/ sizeof (c_double_complex
);
102 ip
= (c_double_complex
*)auxp
->base_addr
;
103 for (i
=0; i
<ex
; i
++, ip
+=sz
)
104 if ((cabs (*ip
-(c_double_complex
)(CMPLX((i
+1), (2*(i
+1)))))>(double)0.0))
106 for (i
=lb
; i
<ub
+1; i
++)
108 ip
= (c_double_complex
*)CFI_address(auxp
, &i
);
109 if ((cabs (*ip
-(c_double_complex
)(CMPLX((i
-lb
+1), (2*(i
-lb
+1)))))>(double)0.0))
116 c_vrfy_c_long_double_complex (const CFI_cdesc_t
*restrict auxp
)
118 CFI_index_t i
, lb
, ub
, ex
;
120 c_long_double_complex
*ip
= NULL
;
123 assert (auxp
->base_addr
);
124 assert (auxp
->elem_len
>0);
125 lb
= auxp
->dim
[0].lower_bound
;
126 ex
= auxp
->dim
[0].extent
;
128 sz
= (size_t)auxp
->elem_len
/ sizeof (c_long_double_complex
);
131 ip
= (c_long_double_complex
*)auxp
->base_addr
;
132 for (i
=0; i
<ex
; i
++, ip
+=sz
)
133 if ((cabsl (*ip
-(c_long_double_complex
)(CMPLXL((i
+1), (2*(i
+1)))))>(long double)0.0))
135 for (i
=lb
; i
<ub
+1; i
++)
137 ip
= (c_long_double_complex
*)CFI_address(auxp
, &i
);
138 if ((cabsl (*ip
-(c_long_double_complex
)(CMPLXL((i
-lb
+1), (2*(i
-lb
+1)))))>(long double)0.0))
145 c_vrfy_c_float128_complex (const CFI_cdesc_t
*restrict auxp
)
147 CFI_index_t i
, lb
, ub
, ex
;
149 c_float128_complex
*ip
= NULL
;
152 assert (auxp
->base_addr
);
153 assert (auxp
->elem_len
>0);
154 lb
= auxp
->dim
[0].lower_bound
;
155 ex
= auxp
->dim
[0].extent
;
157 sz
= (size_t)auxp
->elem_len
/ sizeof (c_float128_complex
);
160 ip
= (c_float128_complex
*)auxp
->base_addr
;
161 for (i
=0; i
<ex
; i
++, ip
+=sz
)
162 if ((cabs ((double complex)(*ip
-(c_float128_complex
)(CMPLX((i
+1), (2*(i
+1))))))>(double)0.0))
164 for (i
=lb
; i
<ub
+1; i
++)
166 ip
= (c_float128_complex
*)CFI_address(auxp
, &i
);
167 if ((cabs ((double complex)(*ip
-(c_float128_complex
)(CMPLX((i
-lb
+1), (2*(i
-lb
+1))))))>(double)0.0))
174 c_vrfy_complex (const CFI_cdesc_t
*restrict auxp
)
176 signed char type
, kind
;
179 type
= _CFI_decode_type(auxp
->type
);
180 kind
= _CFI_decode_kind(auxp
->type
);
181 assert (type
== CFI_type_Complex
);
185 return c_vrfy_c_float_complex (auxp
);
188 return c_vrfy_c_double_complex (auxp
);
191 return c_vrfy_c_long_double_complex (auxp
);
194 return c_vrfy_c_float128_complex (auxp
);
203 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
)
205 signed char ityp
, iknd
;
208 assert (auxp
->elem_len
==elem_len
*nelem
);
209 assert (auxp
->rank
==1);
210 assert (auxp
->dim
[0].sm
>0);
211 assert ((size_t)auxp
->dim
[0].sm
==elem_len
*nelem
);
213 assert (auxp
->type
==type
);
214 ityp
= _CFI_decode_type(auxp
->type
);
215 assert (ityp
== CFI_type_Complex
);
216 iknd
= _CFI_decode_kind(auxp
->type
);
217 assert (_CFI_decode_type(type
)==ityp
);
219 assert (c_vrfy_complex (auxp
));