libgomp: Document 'GOMP_teams4'
[official-gcc.git] / gcc / testsuite / jit.dg / test-sizeof.c
blob6aef9027b4f44f5a15682f09b45a14504ba8b45f
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdint.h>
6 #include "libgccjit.h"
8 #include "harness.h"
10 void
11 create_code (gcc_jit_context *ctxt, void *user_data)
13 /* Let's try to inject the equivalent of:
14 int
15 my_sizeof ()
17 return sizeof(int32_t);
20 gcc_jit_type *int32 =
21 gcc_jit_context_get_int_type (ctxt, 4, 1);
22 gcc_jit_type *int_type =
23 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
25 gcc_jit_function *func =
26 gcc_jit_context_new_function (ctxt,
27 NULL,
28 GCC_JIT_FUNCTION_EXPORTED,
29 int_type,
30 "my_sizeof",
31 0, NULL, 0);
33 gcc_jit_block *initial =
34 gcc_jit_function_new_block (func, "initial");
36 gcc_jit_block_end_with_return(initial, NULL,
37 gcc_jit_context_new_sizeof(ctxt, int32));
40 void
41 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
43 typedef int (*my_sizeof_type) ();
44 CHECK_NON_NULL (result);
45 my_sizeof_type my_sizeof =
46 (my_sizeof_type)gcc_jit_result_get_code (result, "my_sizeof");
47 CHECK_NON_NULL (my_sizeof);
48 int val = my_sizeof ();
49 CHECK_VALUE (val, 4);