Debian Codegraph @

gcc/testsuite/jit.dg/test-error-get-type-bad-enum.c

raw
1 #include <stdlib.h>
2 #include <stdio.h>
3
4 #include "libgccjit.h"
5
6 #include "harness.h"
7
8 void
9 create_code (gcc_jit_context *ctxt, void *user_data)
10 {
11 /* Trigger an API error by passing bad data. */
12 gcc_jit_context_get_type (ctxt, 42);
13 }
14
15 void
16 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
17 {
18 /* Ensure that the bad API usage prevents the API giving a bogus
19 result back. */
20 CHECK_VALUE (result, NULL);
21
22 /* Verify that the correct error message was emitted. */
23 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
24 ("gcc_jit_context_get_type:"
25 " unrecognized value for enum gcc_jit_types: 42"));
26 }
27