9 create_code (gcc_jit_context
*ctxt
, void *user_data
)
11 /* Let's try to inject the equivalent of:
13 int test_bogus_dereference_read (int i)
17 i.e. where i is *not* a pointer.
19 gcc_jit_type
*void_type
=
20 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_VOID
);
21 gcc_jit_type
*int_type
=
22 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
24 /* Build the test function. */
25 gcc_jit_param
*param_i
=
26 gcc_jit_context_new_param (ctxt
, NULL
, int_type
, "i");
27 gcc_jit_function
*test_fn
=
28 gcc_jit_context_new_function (ctxt
, NULL
,
29 GCC_JIT_FUNCTION_EXPORTED
,
31 "test_bogus_dereference_read",
34 gcc_jit_block
*block
= gcc_jit_function_new_block (test_fn
, NULL
);
35 /* Erroneous: "return *i;" */
36 gcc_jit_block_end_with_return (
39 gcc_jit_lvalue_as_rvalue (
40 gcc_jit_rvalue_dereference (
41 gcc_jit_param_as_rvalue (param_i
),
46 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
48 CHECK_VALUE (result
, NULL
);
50 /* Verify that the correct error message was emitted. */
51 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
52 ("gcc_jit_rvalue_dereference:"
53 " dereference of non-pointer i (type: int)"));