| 1 |
/* |
| 2 |
|
| 3 |
Test that the proper error is triggered when we build a register variable |
| 4 |
with a register name that doesn't exist. |
| 5 |
|
| 6 |
*/ |
| 7 |
|
| 8 |
#include <stdlib.h> |
| 9 |
#include <stdio.h> |
| 10 |
|
| 11 |
#include "libgccjit.h" |
| 12 |
#include "harness.h" |
| 13 |
|
| 14 |
void |
| 15 |
create_code (gcc_jit_context *ctxt, void *user_data) |
| 16 |
{ |
| 17 |
gcc_jit_type *int_type = |
| 18 |
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); |
| 19 |
gcc_jit_lvalue *global_variable = |
| 20 |
gcc_jit_context_new_global ( |
| 21 |
ctxt, NULL, GCC_JIT_GLOBAL_EXPORTED, int_type, "global_variable"); |
| 22 |
gcc_jit_lvalue_set_register_name(global_variable, "this_is_not_a_register"); |
| 23 |
} |
| 24 |
|
| 25 |
void |
| 26 |
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) |
| 27 |
{ |
| 28 |
/* Ensure that the bad API usage prevents the API giving a bogus |
| 29 |
result back. */ |
| 30 |
CHECK_VALUE (result, NULL); |
| 31 |
|
| 32 |
/* Verify that the correct error message was emitted. */ |
| 33 |
CHECK_STRING_VALUE (gcc_jit_context_get_last_error (ctxt), |
| 34 |
"invalid register name for 'global_variable'"); |
| 35 |
} |