| 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_new_function (ctxt, NULL, |
| 13 |
GCC_JIT_FUNCTION_EXPORTED, |
| 14 |
NULL, /* error: this must be non-NULL */ |
| 15 |
"hello_world", |
| 16 |
0, NULL, |
| 17 |
0); |
| 18 |
} |
| 19 |
|
| 20 |
void |
| 21 |
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) |
| 22 |
{ |
| 23 |
/* Ensure that the bad API usage prevents the API giving a bogus |
| 24 |
result back. */ |
| 25 |
CHECK_VALUE (result, NULL); |
| 26 |
|
| 27 |
/* Verify that the correct error message was emitted. */ |
| 28 |
CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), |
| 29 |
"gcc_jit_context_new_function: NULL return_type"); |
| 30 |
CHECK_STRING_VALUE (gcc_jit_context_get_last_error (ctxt), |
| 31 |
"gcc_jit_context_new_function: NULL return_type"); |
| 32 |
} |
| 33 |
|