9 create_code (gcc_jit_context
*ctxt
, void *user_data
)
11 /* Let's try to inject the equivalent of:
18 and verify that the API complains about the return
19 of a value within a function with "void" return.
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 gcc_jit_function
*test_fn
=
27 gcc_jit_context_new_function (ctxt
, NULL
,
28 GCC_JIT_FUNCTION_EXPORTED
,
29 void_type
, /* "void" return */
33 gcc_jit_block
*block
= gcc_jit_function_new_block (test_fn
, NULL
);
35 /* "return 42;" (i.e. non-void) */
36 gcc_jit_block_end_with_return (
38 gcc_jit_context_new_rvalue_from_int (ctxt
, int_type
, 42));
42 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
44 /* Ensure that the "return 42" leads to the API giving a NULL
46 CHECK_VALUE (result
, NULL
);
48 /* Verify that the correct error message was emitted. */
49 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
50 "gcc_jit_block_end_with_return:"
51 " mismatching types: return of (int)42 (type: int)"
52 " in function test_fn (return type: void)");