1 #include <stdlib.h>
2 #include <stdio.h>
3 
4 #include "libgccjit.h"
5 
6 #include "harness.h"
7 
8 /* Try to create a local of an opaque struct;
9    the API ought to complain.  */
10 
11 void
create_code(gcc_jit_context * ctxt,void * user_data)12 create_code (gcc_jit_context *ctxt, void *user_data)
13 {
14   gcc_jit_type *t_void =
15     gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
16 
17   gcc_jit_struct *t_opaque =
18     gcc_jit_context_new_opaque_struct (ctxt, NULL, "opaque");
19 
20   gcc_jit_function *func =
21     gcc_jit_context_new_function (ctxt, NULL,
22                                   GCC_JIT_FUNCTION_EXPORTED,
23                                   t_void,
24                                   "test_fn",
25 				  0, NULL,
26                                   0);
27 
28   (void)gcc_jit_function_new_local (func, NULL,
29 				    gcc_jit_struct_as_type (t_opaque),
30 				    "i");
31 }
32 
33 void
verify_code(gcc_jit_context * ctxt,gcc_jit_result * result)34 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
35 {
36   CHECK_VALUE (result, NULL);
37 
38   /* Verify that the correct error message was emitted.  */
39   CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
40 		      "gcc_jit_function_new_local:"
41 		      " unknown size for local \"i\" (type: struct opaque)");
42 }
43