Fix signedness of compares expanding debug exprs.
[official-gcc.git] / libffi / testsuite / libffi.call / struct3.c
blob7eba0ead6d6a8964263a7df59a52d7d28ec27a83
1 /* Area: ffi_call
2 Purpose: Check structures.
3 Limitations: none.
4 PR: none.
5 Originator: From the original ffitest.c */
7 /* { dg-do run } */
8 #include "ffitest.h"
10 typedef struct
12 int si;
13 } test_structure_3;
15 static test_structure_3 ABI_ATTR struct3(test_structure_3 ts)
17 ts.si = -(ts.si*2);
19 return ts;
22 int main (void)
24 ffi_cif cif;
25 ffi_type *args[MAX_ARGS];
26 void *values[MAX_ARGS];
27 int compare_value;
28 ffi_type ts3_type;
29 ffi_type *ts3_type_elements[2];
31 test_structure_3 ts3_arg;
32 test_structure_3 *ts3_result =
33 (test_structure_3 *) malloc (sizeof(test_structure_3));
35 ts3_type.size = 0;
36 ts3_type.alignment = 0;
37 ts3_type.type = FFI_TYPE_STRUCT;
38 ts3_type.elements = ts3_type_elements;
39 ts3_type_elements[0] = &ffi_type_sint;
40 ts3_type_elements[1] = NULL;
42 args[0] = &ts3_type;
43 values[0] = &ts3_arg;
45 /* Initialize the cif */
46 CHECK(ffi_prep_cif(&cif, ABI_NUM, 1,
47 &ts3_type, args) == FFI_OK);
49 ts3_arg.si = -123;
50 compare_value = ts3_arg.si;
52 ffi_call(&cif, FFI_FN(struct3), ts3_result, values);
54 printf ("%d %d\n", ts3_result->si, -(compare_value*2));
56 CHECK(ts3_result->si == -(compare_value*2));
58 free (ts3_result);
59 exit(0);