3 Test that the proper error is triggered when we build a ctor
4 for an union type, but don't provide a correct field.
11 #include "libgccjit.h"
15 create_code (gcc_jit_context
*ctxt
, void *user_data
)
17 gcc_jit_type
*int_type
= gcc_jit_context_get_type (ctxt
,
19 gcc_jit_type
*float_type
= gcc_jit_context_get_type (ctxt
,
21 gcc_jit_type
*double_type
= gcc_jit_context_get_type (ctxt
,
24 gcc_jit_field
*b1
= gcc_jit_context_new_field (ctxt
,
28 gcc_jit_field
*b2
= gcc_jit_context_new_field (ctxt
,
32 gcc_jit_field
*b3
= gcc_jit_context_new_field (ctxt
,
36 gcc_jit_field
*fields_b
[] = {b1
, b2
, b3
};
38 gcc_jit_type
*union_bar_type
=
39 gcc_jit_context_new_union_type (ctxt
,
45 gcc_jit_field
*b33
= gcc_jit_context_new_field (ctxt
,
51 gcc_jit_context_new_rvalue_from_double (ctxt
, double_type
, 1);
53 gcc_jit_rvalue
*ctor
= gcc_jit_context_new_union_constructor
59 CHECK_VALUE (ctor
, NULL
);
63 verify_code (gcc_jit_context
*ctxt
, gcc_jit_result
*result
)
65 /* Ensure that the bad API usage prevents the API giving a bogus
67 CHECK_VALUE (result
, NULL
);
69 /* Verify that the correct error message was emitted. */
70 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt
),
71 "gcc_jit_context_new_union_constructor: field object (c)"
72 " was not used when creating the type union bar");
73 CHECK_STRING_VALUE (gcc_jit_context_get_last_error (ctxt
),
74 "gcc_jit_context_new_union_constructor: field object (c)"
75 " was not used when creating the type union bar");