(root)/
gcc-13.2.0/
gcc/
testsuite/
jit.dg/
test-error-gcc_jit_context_new_global-opaque-struct.c
       1  #include <stdlib.h>
       2  #include <stdio.h>
       3  
       4  #include "libgccjit.h"
       5  
       6  #include "harness.h"
       7  
       8  /* Try to create a global of an opaque struct;
       9     the API ought to complain.  */
      10  
      11  void
      12  create_code (gcc_jit_context *ctxt, void *user_data)
      13  {
      14    gcc_jit_struct *t_opaque =
      15      gcc_jit_context_new_opaque_struct (ctxt, NULL, "opaque");
      16  
      17    (void)gcc_jit_context_new_global (ctxt, NULL,
      18  				    GCC_JIT_GLOBAL_EXPORTED,
      19  				    gcc_jit_struct_as_type (t_opaque),
      20  				    "instance_of_opaque");
      21  }
      22  
      23  void
      24  verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
      25  {
      26    CHECK_VALUE (result, NULL);
      27  
      28    /* Verify that the correct error message was emitted.  */
      29    CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
      30  		      "gcc_jit_context_new_global:"
      31  		      " unknown size for global \"instance_of_opaque\" (type: struct opaque)");
      32  }