| 1 |
/* { dg-do compile { target x86_64-*-* } } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
#include <stdio.h> |
| 5 |
|
| 6 |
#include "libgccjit.h" |
| 7 |
|
| 8 |
#include "harness.h" |
| 9 |
|
| 10 |
void |
| 11 |
create_code (gcc_jit_context *ctxt, void *user_data) |
| 12 |
{ |
| 13 |
gcc_jit_context_add_command_line_option (ctxt, "-flto"); |
| 14 |
gcc_jit_context_add_driver_option (ctxt, "-nostdlib"); |
| 15 |
#if __APPLE__ |
| 16 |
/* On newer macOS, the test will fail with a complaint from the linker about |
| 17 |
all user-land exes needing libSystem, so add it. */ |
| 18 |
gcc_jit_context_add_driver_option (ctxt, "-lSystem"); |
| 19 |
#endif |
| 20 |
|
| 21 |
gcc_jit_type *type_int = gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); |
| 22 |
gcc_jit_param *params_for_func_main[0] = { |
| 23 |
}; |
| 24 |
gcc_jit_function *func_main = |
| 25 |
gcc_jit_context_new_function (ctxt, NULL, GCC_JIT_FUNCTION_EXPORTED, |
| 26 |
type_int, "main", 0, params_for_func_main, |
| 27 |
0); |
| 28 |
gcc_jit_block *block_start = |
| 29 |
gcc_jit_function_new_block (func_main, "start"); |
| 30 |
gcc_jit_rvalue *rvalue__int_42 = |
| 31 |
gcc_jit_context_new_rvalue_from_int (ctxt, type_int, 42); |
| 32 |
gcc_jit_block_end_with_return (block_start, NULL, rvalue__int_42); |
| 33 |
} |
| 34 |
|
| 35 |
void |
| 36 |
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) |
| 37 |
{ |
| 38 |
CHECK_NON_NULL (result); |
| 39 |
} |