Debian Codegraph @

gcc/testsuite/jit.dg/test-alias-attribute.c

raw
1 /* { dg-do compile { target x86_64-*-* } } */
2 /* { dg-require-alias "" } */
3
4 #include <stdlib.h>
5 #include <stdio.h>
6
7 #include "libgccjit.h"
8
9 #define TEST_COMPILING_TO_FILE
10 #define OUTPUT_KIND GCC_JIT_OUTPUT_KIND_ASSEMBLER
11 #define OUTPUT_FILENAME "output-of-test-alias-attribute.c.s"
12 #include "harness.h"
13
14 void
15 create_code (gcc_jit_context *ctxt, void *user_data)
16 {
17 /* Let's try to inject the equivalent of:
18
19 void xxx () {}
20 void f () __attribute__ ((alias ("xxx")));
21 */
22 gcc_jit_type *void_type =
23 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
24
25 /* Creating the `xxx` function. */
26 gcc_jit_function *xxx_func =
27 gcc_jit_context_new_function (ctxt, NULL,
28 GCC_JIT_FUNCTION_EXPORTED,
29 void_type,
30 "xxx",
31 0, NULL,
32 0);
33
34 /* Creating the `f` function. */
35 gcc_jit_function *f_func =
36 gcc_jit_context_new_function (ctxt, NULL,
37 GCC_JIT_FUNCTION_IMPORTED,
38 void_type,
39 "f",
40 0, NULL,
41 0);
42 gcc_jit_function_add_string_attribute(f_func, GCC_JIT_FN_ATTRIBUTE_ALIAS, "xxx");
43
44 /* void xxx () {} */
45 gcc_jit_block *block = gcc_jit_function_new_block (xxx_func, NULL);
46 gcc_jit_block_end_with_void_return (block, NULL);
47 }
48
49 /* { dg-final { jit-verify-output-file-was-created "" } } */
50 /* Check that the attribute was applied correctly */
51 /* { dg-final { jit-verify-assembler-output ".set\\s+f,xxx" } } */