1 #include <stdlib.h>
2 #include <stdio.h>
3
4 #include "libgccjit.h"
5
6 #include "harness.h"
7
8 /* Try to create an unary operator with invalid result type. */
9
10 void
create_code(gcc_jit_context * ctxt,void * user_data)11 create_code (gcc_jit_context *ctxt, void *user_data)
12 {
13 gcc_jit_type *int_type =
14 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
15 gcc_jit_type *void_ptr_type =
16 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID_PTR);
17
18 gcc_jit_context_new_unary_op (
19 ctxt,
20 NULL,
21 GCC_JIT_UNARY_OP_LOGICAL_NEGATE,
22 void_ptr_type,
23 gcc_jit_context_new_rvalue_from_int (ctxt,
24 int_type,
25 1));
26 }
27
28 void
verify_code(gcc_jit_context * ctxt,gcc_jit_result * result)29 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
30 {
31 CHECK_VALUE (result, NULL);
32
33 /* Verify that the correct error message was emitted. */
34 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
35 "gcc_jit_context_new_unary_op: gcc_jit_unary_op "
36 "GCC_JIT_UNARY_OP_LOGICAL_NEGATE with operand "
37 "(int)1 has non-numeric result_type: void *");
38 }
39