| 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 |
/* Let's try to access an array at an index that isn't of a numeric |
| 12 |
type and verify that the API complains about the bad type. |
| 13 |
*/ |
| 14 |
gcc_jit_rvalue *string = |
| 15 |
gcc_jit_context_new_string_literal (ctxt, |
| 16 |
"hello world"); |
| 17 |
|
| 18 |
(void)gcc_jit_context_new_array_access ( |
| 19 |
ctxt, NULL, |
| 20 |
string, /* ptr */ |
| 21 |
string /* index, not of numeric type */); |
| 22 |
} |
| 23 |
|
| 24 |
void |
| 25 |
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) |
| 26 |
{ |
| 27 |
CHECK_VALUE (result, NULL); |
| 28 |
|
| 29 |
/* Verify that the correct error message was emitted. */ |
| 30 |
CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), |
| 31 |
"gcc_jit_context_new_array_access:" |
| 32 |
" index: \"hello world\" (type: const char *)" |
| 33 |
" is not of numeric type"); |
| 34 |
} |