10 create_code (gcc_jit_context
*ctxt
, void *user_data
)
12 /* Let's try to inject the equivalent of:
28 and verify that we get an error about the overlapping
32 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
33 gcc_jit_type
*return_type
= t_int
;
35 gcc_jit_context_new_param (ctxt
, NULL
, t_int
, "x");
36 gcc_jit_param
*params
[1] = {x
};
37 gcc_jit_function
*func
=
38 gcc_jit_context_new_function (ctxt
, NULL
,
39 GCC_JIT_FUNCTION_EXPORTED
,
44 gcc_jit_block
*b_initial
=
45 gcc_jit_function_new_block (func
, "initial");
47 gcc_jit_block
*b_default
=
48 gcc_jit_function_new_block (func
, "default");
49 gcc_jit_block
*b_case_0_5
=
50 gcc_jit_function_new_block (func
, "case_0_5");
51 gcc_jit_block
*b_case_5_10
=
52 gcc_jit_function_new_block (func
, "case_5_10");
54 gcc_jit_case
*cases
[2] = {
55 gcc_jit_context_new_case (
57 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 0),
58 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 5),
60 gcc_jit_context_new_case (
62 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 5),
63 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 10),
67 gcc_jit_block_end_with_switch (
69 gcc_jit_param_as_rvalue (x
),
74 gcc_jit_block_end_with_return (
76 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 3));
77 gcc_jit_block_end_with_return (
79 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 4));
80 gcc_jit_block_end_with_return (
82 gcc_jit_context_new_rvalue_from_int (ctxt
, t_int
, 10));
86 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
88 CHECK_VALUE (result
, NULL
);
90 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
91 "gcc_jit_block_end_with_switch:"
92 " duplicate (or overlapping) cases values:"
93 " case 1: case (int)5 ... (int)10: goto case_5_10;"
94 " overlaps case (int)0 ... (int)5: goto case_0_5;");