c++: prvalue of array type [PR111286]
[official-gcc.git] / gcc / testsuite / jit.dg / test-error-gcc_jit_lvalue_get_address-bitfield.c
blobf102a6a7389e3d04751c8bc7b6d9277724d95f51
1 #include <stdlib.h>
2 #include <stdio.h>
4 #include "libgccjit.h"
6 #include "harness.h"
8 /* Try to dereference a bit-field. */
10 void
11 create_code (gcc_jit_context *ctxt, void *user_data)
13 /* Let's try to inject the equivalent of:
15 struct bit_foo
17 int i:3;
18 int j:3;
21 struct bit_foo f;
22 &(f.j)
24 gcc_jit_type *int_type =
25 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
26 gcc_jit_field *i =
27 gcc_jit_context_new_bitfield (ctxt,
28 NULL,
29 int_type,
31 "i");
32 gcc_jit_field *j =
33 gcc_jit_context_new_bitfield (ctxt,
34 NULL,
35 int_type,
37 "j");
38 gcc_jit_field *fields[] = {i, j};
39 gcc_jit_type *struct_type =
40 gcc_jit_struct_as_type (
41 gcc_jit_context_new_struct_type (ctxt, NULL, "bit_foo", 2, fields));
43 gcc_jit_lvalue *f_struct =
44 gcc_jit_context_new_global (ctxt,
45 NULL,
46 GCC_JIT_GLOBAL_INTERNAL,
47 struct_type,
48 "f");
50 gcc_jit_lvalue_get_address (
51 gcc_jit_lvalue_access_field (
52 f_struct,
53 NULL,
54 j),
55 NULL);
58 void
59 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
61 CHECK_VALUE (result, NULL);
63 /* Verify that the correct error message was emitted. */
64 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
65 "cannot take address of bit-field");