10 create_code (gcc_jit_context
*ctxt
, void *user_data
)
12 /* Let's try to inject the equivalent of:
25 and verify that we get a sane error about the non-const
29 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
30 gcc_jit_type
*return_type
= t_int
;
32 gcc_jit_context_new_param (ctxt
, NULL
, t_int
, "x");
33 gcc_jit_param
*params
[1] = {x
};
34 gcc_jit_function
*func
=
35 gcc_jit_context_new_function (ctxt
, NULL
,
36 GCC_JIT_FUNCTION_EXPORTED
,
41 gcc_jit_block
*b_initial
=
42 gcc_jit_function_new_block (func
, "initial");
44 gcc_jit_block
*b_default
=
45 gcc_jit_function_new_block (func
, "default");
46 gcc_jit_block
*b_case_x
=
47 gcc_jit_function_new_block (func
, "case_x");
49 /* Erroneous use of non-const x for a case. */
50 gcc_jit_case
*cases
[1] = {
51 gcc_jit_context_new_case (
53 gcc_jit_param_as_rvalue (x
),
54 gcc_jit_param_as_rvalue (x
),
58 gcc_jit_block_end_with_switch (
60 gcc_jit_param_as_rvalue (x
),
64 gcc_jit_block_end_with_return (
66 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 3));
67 gcc_jit_block_end_with_return (
69 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 10));
73 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
75 CHECK_VALUE (result
, NULL
);
77 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
78 "gcc_jit_context_new_case:"
79 " min_value is not a constant: x");