c++: prvalue of array type [PR111286]
[official-gcc.git] / gcc / testsuite / jit.dg / test-error-param-reuse.c
blob32cb0c015c1b77fb6077f7f848b1496c213bb67a
1 #include <stdlib.h>
2 #include <stdio.h>
4 #include "libgccjit.h"
6 #include "harness.h"
8 void
9 create_code (gcc_jit_context *ctxt, void *user_data)
11 /* Verify that we get an error (rather than a crash)
12 if the client code reuses a gcc_jit_param * within
13 a function. */
14 gcc_jit_type *void_type =
15 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
16 gcc_jit_type *int_type =
17 gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
19 /* Create a param. */
20 gcc_jit_param *param =
21 gcc_jit_context_new_param (ctxt, NULL, int_type, "i");
23 /* Try to use it twice when creating "fn". */
24 gcc_jit_param *params[2];
25 params[0] = param;
26 params[1] = param;
28 gcc_jit_context_new_function (ctxt, NULL,
29 GCC_JIT_FUNCTION_IMPORTED,
30 void_type,
31 "fn",
32 2, params,
33 0);
36 void
37 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
39 CHECK_VALUE (result, NULL);
41 /* Verify that the correct error message was emitted. */
42 CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
43 ("gcc_jit_context_new_function:"
44 " parameter i (type: int)"
45 " is used more than once when creating function"
46 " fn"))