10 create_code (gcc_jit_context
*ctxt
, void *user_data
)
12 /* Let's try to inject the equivalent of:
24 where the destination block is in another function.
26 gcc_jit_type
*void_t
=
27 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_VOID
);
29 /* Build the test_fn. */
30 gcc_jit_function
*test_fn
=
31 gcc_jit_context_new_function (ctxt
, NULL
,
32 GCC_JIT_FUNCTION_EXPORTED
,
37 /* Build the other_fn. */
38 gcc_jit_function
*other_fn
=
39 gcc_jit_context_new_function (ctxt
, NULL
,
40 GCC_JIT_FUNCTION_EXPORTED
,
46 gcc_jit_block
*initial
=
47 gcc_jit_function_new_block (test_fn
, "initial");
48 gcc_jit_block
*block_within_other_fn
=
49 gcc_jit_function_new_block (other_fn
, "block_within_other_fn");
51 gcc_jit_block_end_with_jump (initial
, NULL
, block_within_other_fn
);
55 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
57 CHECK_VALUE (result
, NULL
);
59 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
60 "gcc_jit_block_end_with_jump:"
61 " target block is not in same function:"
62 " source block initial is in function test_fn"
63 " whereas target block block_within_other_fn"
64 " is in function other_fn");
65 /* Example of a testcase in which the last error != first error. */
66 CHECK_STRING_VALUE (gcc_jit_context_get_last_error (ctxt
),
67 "unterminated block in other_fn: block_within_other_fn");