PR lto/84212 - -Wno-* does not disable warnings from -flto link stage
[official-gcc.git] / gcc / testsuite / jit.dg / test-validly-unreachable-block.c
blob2664818992ac8038303b1b1146d390902e2385cc
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, but have it
21 survive validation (PR jit/66546).
23 gcc_jit_context_set_bool_allow_unreachable_blocks (ctxt, 1);
25 gcc_jit_type *void_t =
26 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
28 /* Build the test_fn. */
29 gcc_jit_function *test_fn =
30 gcc_jit_context_new_function (ctxt, NULL,
31 GCC_JIT_FUNCTION_EXPORTED,
32 void_t,
33 "test_fn",
34 0, NULL,
35 0);
36 gcc_jit_block *initial =
37 gcc_jit_function_new_block (test_fn, "a");
38 gcc_jit_block *unreachable =
39 gcc_jit_function_new_block (test_fn, "b");
41 gcc_jit_block_end_with_void_return (initial, NULL);
43 gcc_jit_block_end_with_void_return (unreachable, NULL);
46 void
47 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
49 /* Ensure that the "unreachable blocks" validator was ignored. */
50 CHECK_NON_NULL (result);