c++: prvalue of array type [PR111286]
[official-gcc.git] / gcc / testsuite / jit.dg / test-error-param-sharing.c
blob036049c58660a2b3d17fbb6028680d8ba592faa2
1 #include <stdlib.h>
2 #include <stdio.h>
4 #include "libgccjit.h"
6 #include "harness.h"
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
12 extern void
13 called_function (void *ptr);
15 #ifdef __cplusplus
17 #endif
19 void
20 create_code (gcc_jit_context *ctxt, void *user_data)
22 /* Verify that we get an error (rather than a crash)
23 if the client code reuses a gcc_jit_param * for
24 two different functions. */
25 gcc_jit_type *void_type =
26 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
27 gcc_jit_type *int_type =
28 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
30 /* Create a param. */
31 gcc_jit_param *param =
32 gcc_jit_context_new_param (ctxt, NULL, int_type, "i");
34 /* Try to use it for two different functions. */
35 gcc_jit_context_new_function (ctxt, NULL,
36 GCC_JIT_FUNCTION_EXPORTED,
37 void_type,
38 "fn_one",
39 1, &param,
40 0);
41 gcc_jit_context_new_function (ctxt, NULL,
42 GCC_JIT_FUNCTION_EXPORTED,
43 void_type,
44 "fn_two",
45 1, &param,
46 0);
49 void
50 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
52 CHECK_VALUE (result, NULL);
54 /* Verify that the correct error message was emitted. */
55 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
56 ("gcc_jit_context_new_function:"
57 " parameter 0 \"i\" (type: int)"
58 " for function fn_two"
59 " was already used for function fn_one"))