2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / jit.dg / test-error-unreachable-block.c
blob10806bd69863c51003a0763cd8e3faf57549f48e
1 #include <math.h>
2 #include <stdlib.h>
3 #include <stdio.h>
5 #include "libgccjit.h"
7 #include "harness.h"
9 void
10 create_code (gcc_jit_context *ctxt, void *user_data)
12 /* Let's try to inject the equivalent of:
13 void
14 test_fn ()
16 return;
18 return;
20 where the second block is unreachable.
22 gcc_jit_type *void_t =
23 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
25 /* Build the test_fn. */
26 gcc_jit_function *test_fn =
27 gcc_jit_context_new_function (ctxt, NULL,
28 GCC_JIT_FUNCTION_EXPORTED,
29 void_t,
30 "test_fn",
31 0, NULL,
32 0);
33 gcc_jit_block *initial =
34 gcc_jit_function_new_block (test_fn, "a");
35 gcc_jit_block *unreachable =
36 gcc_jit_function_new_block (test_fn, "b");
38 gcc_jit_block_end_with_void_return (initial, NULL);
40 gcc_jit_block_end_with_void_return (unreachable, NULL);
43 void
44 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
46 CHECK_VALUE (result, NULL);
48 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
49 "unreachable block: b");