9 create_code (gcc_jit_context
*ctxt
, void *user_data
)
11 /* Let's try to inject the equivalent of:
25 and verify that the API complains about the use of the local
26 from the other function. */
27 gcc_jit_type
*void_type
=
28 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_VOID
);
29 gcc_jit_type
*int_type
=
30 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
32 gcc_jit_function
*fn_one
=
33 gcc_jit_context_new_function (ctxt
, NULL
,
34 GCC_JIT_FUNCTION_EXPORTED
,
39 gcc_jit_lvalue
*local
=
40 gcc_jit_function_new_local (fn_one
, NULL
, int_type
, "i");
42 gcc_jit_function
*fn_two
=
43 gcc_jit_context_new_function (ctxt
, NULL
,
44 GCC_JIT_FUNCTION_EXPORTED
,
50 gcc_jit_block
*block
= gcc_jit_function_new_block (fn_two
, NULL
);
51 /* "return i;", using local i from the wrong function. */
52 gcc_jit_block_end_with_return (block
,
54 gcc_jit_lvalue_as_rvalue (local
));
58 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
60 CHECK_VALUE (result
, NULL
);
62 /* Verify that the correct error message was emitted. */
63 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
64 ("gcc_jit_block_end_with_return:"
65 " rvalue i (type: int)"
66 " has scope limited to function fn_one"
67 " but was used within function fn_two"
68 " (in statement: return i;)"));