| 1 |
/* Test the fix of PR89846. |
| 2 |
|
| 3 |
Contributed by Reinhold Bader <[email protected]>#include <stdio.h> */ |
| 4 |
|
| 5 |
#include <stdlib.h> |
| 6 |
#include <stddef.h> |
| 7 |
#include <stdio.h> |
| 8 |
#include <ISO_Fortran_binding.h> |
| 9 |
|
| 10 |
typedef struct |
| 11 |
{ |
| 12 |
char n; |
| 13 |
float r[2]; |
| 14 |
} t1; |
| 15 |
|
| 16 |
typedef struct |
| 17 |
{ |
| 18 |
long int i; |
| 19 |
t1 t1; |
| 20 |
} t2; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
void ta0(CFI_cdesc_t *); |
| 25 |
void ta1(CFI_cdesc_t *); |
| 26 |
|
| 27 |
void ti(CFI_cdesc_t *this, int flag) |
| 28 |
{ |
| 29 |
int status; |
| 30 |
size_t dis; |
| 31 |
CFI_CDESC_T(1) that; |
| 32 |
t1 *ans; |
| 33 |
|
| 34 |
switch (flag) |
| 35 |
{ |
| 36 |
case 0: |
| 37 |
dis = offsetof(t2, t1); |
| 38 |
status = CFI_establish((CFI_cdesc_t *) &that, NULL, CFI_attribute_other, |
| 39 |
CFI_type_struct, sizeof(t1), 1, NULL); |
| 40 |
if (status != CFI_SUCCESS) |
| 41 |
{ |
| 42 |
printf("FAIL 1 establish: nonzero status %i\n",status); |
| 43 |
exit(1); |
| 44 |
} |
| 45 |
status = CFI_select_part((CFI_cdesc_t *) &that, this, dis, 0); |
| 46 |
if (status != CFI_SUCCESS) |
| 47 |
{ |
| 48 |
printf("FAIL C1: nonzero status %i\n",status); |
| 49 |
exit(1); |
| 50 |
} |
| 51 |
break; |
| 52 |
|
| 53 |
case 1: |
| 54 |
dis = offsetof(t2, i); |
| 55 |
status = CFI_establish((CFI_cdesc_t *) &that, NULL, CFI_attribute_other, |
| 56 |
CFI_type_long, 0, 1, NULL); |
| 57 |
if (status != CFI_SUCCESS) |
| 58 |
{ |
| 59 |
printf("FAIL 2 establish: nonzero status %i\n",status); |
| 60 |
exit(1); |
| 61 |
} |
| 62 |
status = CFI_select_part((CFI_cdesc_t *) &that, this, dis, 0); |
| 63 |
if (status != CFI_SUCCESS) |
| 64 |
{ |
| 65 |
printf("FAIL C2: nonzero status %i\n",status); |
| 66 |
exit(1); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
if (CFI_is_contiguous((CFI_cdesc_t *) &that)) |
| 71 |
{ |
| 72 |
printf("FAIL C: contiguity for flag value %i - is %i\n",flag, |
| 73 |
CFI_is_contiguous((CFI_cdesc_t *) &that)); |
| 74 |
} |
| 75 |
|
| 76 |
if (flag == 0) ta0((CFI_cdesc_t *) &that); |
| 77 |
if (flag == 1) ta1((CFI_cdesc_t *) &that); |
| 78 |
} |