5 create_code (gcc_jit_context
*ctxt
, void *user_data
)
7 /* Try to inject the equivalent of:
11 idx += (unsigned char)1; // mismatching type
13 and verify that we don't get an ICE inside gimplification
14 due to the type mismatch. */
15 gcc_jit_type
*void_type
=
16 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_VOID
);
17 gcc_jit_type
*int_type
=
18 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
19 gcc_jit_type
*unsigned_char_type
=
20 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_UNSIGNED_CHAR
);
21 gcc_jit_function
*test_func
=
22 gcc_jit_context_new_function (ctxt
, /* gcc_jit_context *ctxt */
23 NULL
, /* gcc_jit_location *loc */
24 GCC_JIT_FUNCTION_EXPORTED
, /* enum gcc_jit_function_kind kind */
25 void_type
, /* gcc_jit_type *return_type */
26 "test_func", /* const char *name */
27 0, /* int num_params */
28 NULL
, /* gcc_jit_param **params */
29 0); /* int is_variadic */
30 gcc_jit_block
*block
=
31 gcc_jit_function_new_block (test_func
, "initial");
33 gcc_jit_rvalue
*unsigned_char_1
=
34 gcc_jit_context_new_rvalue_from_int (ctxt
, /* gcc_jit_context *ctxt */
35 unsigned_char_type
, /* gcc_jit_type *numeric_type */
38 gcc_jit_context_new_global (ctxt
, /* gcc_jit_context *ctxt */
39 NULL
, /* gcc_jit_location *loc */
40 GCC_JIT_GLOBAL_INTERNAL
, /* enum gcc_jit_global_kind kind */
41 int_type
, /* gcc_jit_type *type */
42 "idx"); /* const char *name */
44 gcc_jit_block_add_assignment_op (block
, /*gcc_jit_block *block */
45 NULL
, /* gcc_jit_location *loc */
46 idx
, /* gcc_jit_lvalue *lvalue */
47 GCC_JIT_BINARY_OP_PLUS
, /* enum gcc_jit_binary_op op */
48 unsigned_char_1
); /* gcc_jit_rvalue *rvalue */
49 gcc_jit_block_end_with_void_return (block
, /*gcc_jit_block *block */
54 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
56 CHECK_VALUE (result
, NULL
);
58 /* Verify that the correct error message was emitted. */
59 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
60 "gcc_jit_block_add_assignment_op:"
62 " assignment to idx (type: int)"
63 " involving (unsigned char)1 (type: unsigned char)")