9 create_code (gcc_jit_context
*ctxt
, void *user_data
)
11 /* Let's try to inject the equivalent of:
15 extern void called_function (struct foo *ptr);
24 and verify that we get a type error (foo * vs foo).
26 gcc_jit_type
*void_type
=
27 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_VOID
);
28 gcc_jit_struct
*struct_foo
=
29 gcc_jit_context_new_struct_type (ctxt
, NULL
, "foo", 0, NULL
);
30 gcc_jit_type
*foo_ptr
=
31 gcc_jit_type_get_pointer (gcc_jit_struct_as_type (struct_foo
));
32 gcc_jit_param
*param
=
33 gcc_jit_context_new_param (ctxt
, NULL
, foo_ptr
, "ptr");
35 gcc_jit_function
*called_function
=
36 gcc_jit_context_new_function (ctxt
, NULL
,
37 GCC_JIT_FUNCTION_IMPORTED
,
43 gcc_jit_function
*test_fn
=
44 gcc_jit_context_new_function (ctxt
, NULL
,
45 GCC_JIT_FUNCTION_EXPORTED
,
51 gcc_jit_function_new_local (
52 test_fn
, NULL
, gcc_jit_struct_as_type (struct_foo
), "f");
54 gcc_jit_block
*block
= gcc_jit_function_new_block (test_fn
, NULL
);
56 gcc_jit_rvalue
*arg
= gcc_jit_lvalue_as_rvalue (f
);
58 gcc_jit_block_add_eval (
60 gcc_jit_context_new_call (
64 gcc_jit_block_end_with_void_return (block
, NULL
);
68 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
70 CHECK_VALUE (result
, NULL
);
72 /* Verify that the correct error message was emitted. */
73 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
74 "gcc_jit_context_new_call:"
75 " mismatching types for argument 1"
76 " of function \"called_function\":"
77 " assignment to param ptr (type: struct foo *)"
78 " from f (type: struct foo)");