Add qdf24xx base tuning support.
[official-gcc.git] / gcc / testsuite / jit.dg / test-error-dereference-read-of-non-pointer.c
blob7b97ab16658686009f2048f0b9909be51e47531f
1 #include <stdlib.h>
2 #include <stdio.h>
4 #include "libgccjit.h"
6 #include "harness.h"
8 void
9 create_code (gcc_jit_context *ctxt, void *user_data)
11 /* Let's try to inject the equivalent of:
12 void
13 int test_bogus_dereference_read (int i)
15 return *i;
17 i.e. where i is *not* a pointer.
19 gcc_jit_type *void_type =
20 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
21 gcc_jit_type *int_type =
22 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
24 /* Build the test function. */
25 gcc_jit_param *param_i =
26 gcc_jit_context_new_param (ctxt, NULL, int_type, "i");
27 gcc_jit_function *test_fn =
28 gcc_jit_context_new_function (ctxt, NULL,
29 GCC_JIT_FUNCTION_EXPORTED,
30 void_type,
31 "test_bogus_dereference_read",
32 1, &param_i,
33 0);
34 gcc_jit_block *block = gcc_jit_function_new_block (test_fn, NULL);
35 /* Erroneous: "return *i;" */
36 gcc_jit_block_end_with_return (
37 block,
38 NULL,
39 gcc_jit_lvalue_as_rvalue (
40 gcc_jit_rvalue_dereference (
41 gcc_jit_param_as_rvalue (param_i),
42 NULL)));
45 void
46 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
48 CHECK_VALUE (result, NULL);
50 /* Verify that the correct error message was emitted. */
51 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
52 ("gcc_jit_rvalue_dereference:"
53 " dereference of non-pointer i (type: int)"));