]> gcc.gnu.org Git - gcc.git/blob - gcc/testsuite/gfortran.dg/pr93524.c
testsuite/lib/gfortran.exp: Add -I for ISO*.h [PR101305, PR101660]
[gcc.git] / gcc / testsuite / gfortran.dg / pr93524.c
1 /* Test the fix for PR93524, in which CFI_allocate was computing
2 sm incorrectly for dimensions > 2. */
3
4 #include <stdlib.h> // For size_t
5 #include <ISO_Fortran_binding.h>
6
7 void my_fortran_sub_1 (CFI_cdesc_t *dv);
8 void my_fortran_sub_2 (CFI_cdesc_t *dv);
9
10 int main ()
11 {
12 CFI_CDESC_T (3) a;
13 CFI_cdesc_t *dv = (CFI_cdesc_t *) &a;
14 // dv, base_addr, attribute, type, elem_len, rank, extents
15 CFI_establish (dv, NULL, CFI_attribute_allocatable, CFI_type_float, 0, 3, NULL);
16
17 if (dv->base_addr != NULL)
18 return 1; // shall not be allocated
19
20 CFI_index_t lower_bounds[] = {-10, 0, 3};
21 CFI_index_t upper_bounds[] = {10, 5, 10};
22 size_t elem_len = 0; // only needed for strings
23 if (CFI_SUCCESS != CFI_allocate (dv, lower_bounds, upper_bounds, elem_len))
24 return 2;
25
26 if (!CFI_is_contiguous (dv))
27 return 2; // allocatables shall be contiguous,unless a strided section is used
28
29 my_fortran_sub_1 (dv);
30 my_fortran_sub_2 (dv);
31 CFI_deallocate (dv);
32 return 0;
33 }
This page took 0.034903 seconds and 5 git commands to generate.