9 create_code (gcc_jit_context
*ctxt
, void *user_data
)
11 /* Let's try to inject the equivalent of:
16 ((some_unspecified_fn_ptr_type)42) (43);
19 and verify that the API complains about the 42 not being a
21 gcc_jit_type
*void_type
=
22 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_VOID
);
23 gcc_jit_type
*int_type
=
24 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
26 /* Build the test_fn. */
27 gcc_jit_function
*test_fn
=
28 gcc_jit_context_new_function (ctxt
, NULL
,
29 GCC_JIT_FUNCTION_EXPORTED
,
34 gcc_jit_rvalue
*not_a_function
=
35 gcc_jit_context_new_rvalue_from_int (ctxt
, int_type
, 42);
37 gcc_jit_context_new_rvalue_from_int (ctxt
, int_type
, 43);
39 /* ((some_unspecified_fn_ptr_type)42) (43); */
40 gcc_jit_block
*block
= gcc_jit_function_new_block (test_fn
, NULL
);
41 gcc_jit_block_add_eval (
43 gcc_jit_context_new_call_through_ptr (
46 /* This is not even a pointer, let alone a function pointer. */
49 gcc_jit_block_end_with_void_return (block
, NULL
);
53 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
55 CHECK_VALUE (result
, NULL
);
57 /* Verify that the correct error message was emitted. */
58 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
59 ("gcc_jit_context_new_call_through_ptr:"
60 " fn_ptr is not a ptr: (int)42 type: int"));