9 create_code (gcc_jit_context
*ctxt
, void *user_data
)
11 /* Let's try to inject the equivalent of:
24 and verify that the API complains about the use of the param
25 from the other function. */
26 gcc_jit_type
*void_type
=
27 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_VOID
);
28 gcc_jit_type
*int_type
=
29 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
31 gcc_jit_param
*param
=
32 gcc_jit_context_new_param (ctxt
, NULL
, int_type
, "i");
34 gcc_jit_context_new_function (ctxt
, NULL
,
35 GCC_JIT_FUNCTION_EXPORTED
,
40 gcc_jit_function
*fn_two
=
41 gcc_jit_context_new_function (ctxt
, NULL
,
42 GCC_JIT_FUNCTION_EXPORTED
,
48 gcc_jit_block
*block
= gcc_jit_function_new_block (fn_two
, NULL
);
49 /* "return i * 2;", using param i from the wrong function. */
50 gcc_jit_block_end_with_return (
53 gcc_jit_context_new_binary_op (
55 GCC_JIT_BINARY_OP_MULT
,
57 gcc_jit_param_as_rvalue (param
),
58 gcc_jit_context_new_rvalue_from_int (ctxt
, int_type
, 2)));
62 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
64 CHECK_VALUE (result
, NULL
);
66 /* Verify that the correct error message was emitted. */
67 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
68 ("gcc_jit_block_end_with_return:"
69 " rvalue i (type: int)"
70 " has scope limited to function fn_one"
71 " but was used within function fn_two"
72 " (in statement: return i * (int)2;)"));