| 1 |
/* { dg-do compile { target x86_64-*-* } } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
#include <stdio.h> |
| 5 |
|
| 6 |
#include "libgccjit.h" |
| 7 |
|
| 8 |
/* We don't want set_options() in harness.h to set -O3 so our little local |
| 9 |
is optimized away. */ |
| 10 |
#define TEST_ESCHEWS_SET_OPTIONS |
| 11 |
static void set_options (gcc_jit_context *ctxt, const char *argv0) |
| 12 |
{ |
| 13 |
} |
| 14 |
|
| 15 |
#define TEST_COMPILING_TO_FILE |
| 16 |
#define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER |
| 17 |
#define OUTPUT_FILENAME "output-of-test-readonly.c.s" |
| 18 |
#include "harness.h" |
| 19 |
|
| 20 |
void |
| 21 |
create_code (gcc_jit_context *ctxt, void *user_data) |
| 22 |
{ |
| 23 |
/* Let's try to inject the equivalent of: |
| 24 |
const int foo; |
| 25 |
*/ |
| 26 |
gcc_jit_type *int_type = |
| 27 |
gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); |
| 28 |
gcc_jit_lvalue *foo = |
| 29 |
gcc_jit_context_new_global ( |
| 30 |
ctxt, NULL, GCC_JIT_GLOBAL_EXPORTED, int_type, "foo"); |
| 31 |
|
| 32 |
gcc_jit_rvalue *ten = gcc_jit_context_new_rvalue_from_int (ctxt, int_type, 10); |
| 33 |
gcc_jit_global_set_initializer_rvalue (foo, ten); |
| 34 |
gcc_jit_global_set_readonly(foo); |
| 35 |
} |
| 36 |
|
| 37 |
/* { dg-final { jit-verify-output-file-was-created "" } } */ |
| 38 |
/* { dg-final { jit-verify-assembler-output ".section\t.rodata" } } */ |