[ARM,testsuite] Skip tests incompatible with -mpure-code.
[gcc.git] / gcc / testsuite / jit.dg / test-error-gcc_jit_block_end_with_switch-NULL-case.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #include "libgccjit.h"
6
7 #include "harness.h"
8
9 /* Try to create a switch statement with a NULL case, so that
10 we can verify that we get a sane error message. */
11
12 void
13 create_code (gcc_jit_context *ctxt, void *user_data)
14 {
15 gcc_jit_type *t_int =
16 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
17 gcc_jit_type *return_type = t_int;
18 gcc_jit_param *x =
19 gcc_jit_context_new_param (ctxt, NULL, t_int, "x");
20 gcc_jit_param *params[1] = {x};
21 gcc_jit_function *func =
22 gcc_jit_context_new_function (ctxt, NULL,
23 GCC_JIT_FUNCTION_EXPORTED,
24 return_type,
25 "test_switch",
26 1, params, 0);
27
28 gcc_jit_block *b_initial =
29 gcc_jit_function_new_block (func, "initial");
30
31 gcc_jit_block *b_default =
32 gcc_jit_function_new_block (func, "default");
33
34 /* Erroneous NULL case. */
35 gcc_jit_case *cases[1] = {
36 NULL
37 };
38
39 gcc_jit_block_end_with_switch (
40 b_initial, NULL,
41 gcc_jit_param_as_rvalue (x),
42 b_default,
43 1,
44 cases);
45 }
46
47 void
48 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
49 {
50 CHECK_VALUE (result, NULL);
51
52 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
53 "gcc_jit_block_end_with_switch: NULL case 0");
54 }