1 /* { dg-do compile { target x86_64-*-* } } */
8 #define TEST_ESCHEWS_SET_OPTIONS
9 static void set_options (gcc_jit_context
*ctxt
, const char *argv0
)
12 gcc_jit_context_set_int_option(ctxt
, GCC_JIT_INT_OPTION_OPTIMIZATION_LEVEL
, 2);
15 #define TEST_COMPILING_TO_FILE
16 #define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER
17 #define OUTPUT_FILENAME "output-of-test-nonnull.c.s"
21 create_code (gcc_jit_context
*ctxt
, void *user_data
)
23 /* Let's try to inject the equivalent of:
25 __attribute__((nonnull(1)))
33 gcc_jit_type
*int_type
=
34 gcc_jit_context_get_type (ctxt
, GCC_JIT_TYPE_INT
);
35 gcc_jit_type
*pint_type
= gcc_jit_type_get_pointer(int_type
);
38 gcc_jit_context_new_param (ctxt
, NULL
, pint_type
, "a");
40 gcc_jit_function
*func_t
=
41 gcc_jit_context_new_function (ctxt
, NULL
,
42 GCC_JIT_FUNCTION_EXPORTED
,
47 /* Adding `nonnull(1)` attribute. */
49 gcc_jit_function_add_integer_array_attribute (
51 GCC_JIT_FN_ATTRIBUTE_NONNULL
,
59 gcc_jit_block
*if_cond
=
60 gcc_jit_function_new_block (func_t
, "if_cond");
61 gcc_jit_block
*if_body
=
62 gcc_jit_function_new_block (func_t
, "if_body");
63 gcc_jit_block
*after_if
=
64 gcc_jit_function_new_block (func_t
, "after_if");
67 gcc_jit_block_end_with_conditional (
69 gcc_jit_context_new_comparison (
71 GCC_JIT_COMPARISON_EQ
,
72 gcc_jit_param_as_rvalue (a
),
73 gcc_jit_context_null (ctxt
, pint_type
)),
77 gcc_jit_block_end_with_return (
79 gcc_jit_context_new_rvalue_from_int (ctxt
, int_type
, -1));
82 gcc_jit_block_end_with_return (
84 gcc_jit_lvalue_as_rvalue (
85 gcc_jit_rvalue_dereference (
86 gcc_jit_param_as_rvalue (a
), NULL
)));
89 /* { dg-final { jit-verify-output-file-was-created "" } } */
90 /* Check that the "if block" was optimized away */
91 /* { dg-final { jit-verify-assembler-output-not "testq" } } */
92 /* { dg-final { jit-verify-assembler-output-not "-1" } } */