| 1 |
/* Test the fix for PR89841. */ |
| 2 |
|
| 3 |
/* Contributed by Reinhold Bader <[email protected]> */ |
| 4 |
|
| 5 |
#include <ISO_Fortran_binding.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <math.h> |
| 9 |
|
| 10 |
typedef struct |
| 11 |
{ |
| 12 |
int i; |
| 13 |
float r[2]; |
| 14 |
} cstruct; |
| 15 |
|
| 16 |
|
| 17 |
int Psuba(CFI_cdesc_t *this, CFI_cdesc_t *that, int Dcase) { |
| 18 |
int status = 0; |
| 19 |
cstruct *cu; |
| 20 |
float *ct; |
| 21 |
CFI_dim_t *dim; |
| 22 |
if (this->elem_len != sizeof(float)) |
| 23 |
{ |
| 24 |
printf("FAIL: Dcase %i - this->elem_len %i\n",Dcase, (int) this->elem_len); |
| 25 |
status++; |
| 26 |
} |
| 27 |
if (this->type != CFI_type_float) |
| 28 |
{ |
| 29 |
printf("FAIL: Dcase %i - this->type\n", Dcase); |
| 30 |
status++; |
| 31 |
} |
| 32 |
if (this->rank != 2) |
| 33 |
{ |
| 34 |
printf("FAIL: Dcase %i - this->rank %i\n",Dcase,this->rank); |
| 35 |
status++; |
| 36 |
} |
| 37 |
if (this->attribute != CFI_attribute_other) |
| 38 |
{ |
| 39 |
printf("FAIL: Dcase %i - this->attribute\n", Dcase); |
| 40 |
status++; |
| 41 |
} |
| 42 |
|
| 43 |
dim = this->dim; |
| 44 |
if (dim[0].lower_bound != 0 || dim[0].extent != 3) |
| 45 |
{ |
| 46 |
printf("FAIL: Dcase %i - dim[0] %i %i %i\n",Dcase, (int) dim[0].lower_bound, |
| 47 |
(int)dim[0].extent,(int)dim[0].sm); |
| 48 |
status++; |
| 49 |
} |
| 50 |
if (dim[1].lower_bound != 0 || dim[1].extent != 7) |
| 51 |
{ |
| 52 |
printf("FAIL: Dcase %i - dim[1] %i %i %i\n",Dcase,(int) dim[1].lower_bound, |
| 53 |
(int) dim[1].extent,(int) dim[1].sm); |
| 54 |
status++; |
| 55 |
} |
| 56 |
|
| 57 |
if (that->elem_len != sizeof(cstruct)) |
| 58 |
{ |
| 59 |
printf("FAIL: Dcase %i - that->elem_len\n", Dcase); |
| 60 |
status++; |
| 61 |
} |
| 62 |
if (that->type != CFI_type_struct) |
| 63 |
{ |
| 64 |
printf("FAIL: Dcase %i - that->type\n",Dcase); |
| 65 |
status++; |
| 66 |
} |
| 67 |
if (that->rank != 1) |
| 68 |
{ |
| 69 |
printf("FAIL: Dcase %i - that->rank\n", Dcase); |
| 70 |
status++; |
| 71 |
} |
| 72 |
if (that->attribute != CFI_attribute_other) |
| 73 |
{ |
| 74 |
printf("FAIL: Dcase %i - that->attribute %i\n",Dcase,that->attribute); |
| 75 |
status++; |
| 76 |
} |
| 77 |
|
| 78 |
dim = that->dim; |
| 79 |
if (dim[0].lower_bound != 0 || dim[0].extent != 1) |
| 80 |
{ |
| 81 |
printf("FAIL: Dcase %i - dim[0] %i %i\n",Dcase,(int)dim[0].lower_bound,dim[0].extent); |
| 82 |
status++; |
| 83 |
} |
| 84 |
|
| 85 |
cu = (cstruct *) ((CFI_cdesc_t *) that)->base_addr; |
| 86 |
if (cu->i != 4 || fabs(cu->r[1] - 2.2) > 1.0e-6) |
| 87 |
{ |
| 88 |
printf("FAIL: Dcase %i - value of that %i %f %f\n",Dcase,cu->i,cu->r[0],cu->r[1]); |
| 89 |
status++; |
| 90 |
} |
| 91 |
|
| 92 |
ct = (float *) ((CFI_cdesc_t *) this)->base_addr; |
| 93 |
if ( fabs(ct[5] + 2.0) > 1.0e-6) |
| 94 |
{ |
| 95 |
printf("FAIL: Dcase %i - value of this %f\n",Dcase,ct[5]); |
| 96 |
status++; |
| 97 |
} |
| 98 |
|
| 99 |
return status; |
| 100 |
} |
| 101 |
|
| 102 |
|