Add qdf24xx base tuning support.
[official-gcc.git] / gcc / testsuite / jit.dg / test-error-gcc_jit_context_new_case-reversed-endpoints.c
bloba84d9f33f3dcd30a9a784755e901cb3c6848626d
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.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 int
14 test_switch (int x)
16 switch (x)
18 case 5 ... 0:
19 return 3;
21 default:
22 return 10;
25 and verify that we get an error about the reversed endpoints
26 in the range.
28 gcc_jit_type *t_int =
29 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
30 gcc_jit_type *return_type = t_int;
31 gcc_jit_param *x =
32 gcc_jit_context_new_param (ctxt, NULL, t_int, "x");
33 gcc_jit_param *params[1] = {x};
34 gcc_jit_function *func =
35 gcc_jit_context_new_function (ctxt, NULL,
36 GCC_JIT_FUNCTION_EXPORTED,
37 return_type,
38 "test_switch",
39 1, params, 0);
41 gcc_jit_block *b_initial =
42 gcc_jit_function_new_block (func, "initial");
44 gcc_jit_block *b_default =
45 gcc_jit_function_new_block (func, "default");
46 gcc_jit_block *b_case_5_0 =
47 gcc_jit_function_new_block (func, "case_5_0");
49 gcc_jit_case *cases[1] = {
50 gcc_jit_context_new_case (
51 ctxt,
52 gcc_jit_context_new_rvalue_from_int (ctxt, t_int, 5),
53 gcc_jit_context_new_rvalue_from_int (ctxt, t_int, 0),
54 b_case_5_0)
57 gcc_jit_block_end_with_switch (
58 b_initial, NULL,
59 gcc_jit_param_as_rvalue (x),
60 b_default,
62 cases);
64 gcc_jit_block_end_with_return (
65 b_case_5_0, NULL,
66 gcc_jit_context_new_rvalue_from_int (ctxt, t_int, 3));
67 gcc_jit_block_end_with_return (
68 b_default, NULL,
69 gcc_jit_context_new_rvalue_from_int (ctxt, t_int, 10));
72 void
73 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
75 CHECK_VALUE (result, NULL);
77 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
78 "gcc_jit_context_new_case:"
79 " min_value: (int)5 > max_value: (int)0");