lto: Remove random_seed from section name.
[official-gcc.git] / gcc / testsuite / gfortran.dg / PR94331.c
blobdf571c7583c7f432b385e9467de3ab393db00f60
1 /* Test the fix for PR94331. */
3 #include <assert.h>
4 #include <stdbool.h>
5 #include <stdlib.h>
7 #include <ISO_Fortran_binding.h>
9 bool c_vrfy (const CFI_cdesc_t *restrict);
11 bool check_bounds(const CFI_cdesc_t*restrict, const int, const int);
13 bool
14 c_vrfy (const CFI_cdesc_t *restrict auxp)
16 CFI_index_t i, lb, ub, ex;
17 int *ip = NULL;
19 assert (auxp);
20 assert (auxp->base_addr);
21 lb = auxp->dim[0].lower_bound;
22 ex = auxp->dim[0].extent;
23 ub = ex + lb - 1;
24 ip = (int*)auxp->base_addr;
25 for (i=0; i<ex; i++)
26 if (*ip++ != i+1)
27 return false;
28 for (i=lb; i<ub+1; i++)
30 ip = (int*)CFI_address(auxp, &i);
31 if (*ip != i-lb+1)
32 return false;
34 return true;
37 bool
38 check_bounds (const CFI_cdesc_t *restrict auxp, const int lb, const int ub)
40 CFI_index_t ex = ub-lb+1;
41 size_t el;
42 bool is_ok = false;
44 assert (auxp);
45 el = auxp->elem_len;
46 assert (auxp->rank==1);
47 assert (auxp->type==CFI_type_int);
48 assert (auxp->dim[0].sm>0);
49 assert ((size_t)auxp->dim[0].sm==el);
50 if (auxp->dim[0].extent==ex
51 && auxp->dim[0].lower_bound==lb)
53 switch(auxp->attribute)
55 case CFI_attribute_pointer:
56 case CFI_attribute_allocatable:
57 if (!c_vrfy (auxp))
58 break;
59 is_ok = true;
60 break;
61 case CFI_attribute_other:
62 if (!c_vrfy (auxp))
63 break;
64 is_ok = (lb==0);
65 break;
66 default:
67 assert (false);
68 break;
71 return is_ok;