(root)/
gcc-13.2.0/
gcc/
testsuite/
jit.dg/
test-error-gcc_jit_context_new_field-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 put an opaque struct inside another struct
       9     (or union); 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_field (ctxt, NULL,
      18  				   gcc_jit_struct_as_type (t_opaque),
      19  				   "f_opaque");
      20  }
      21  
      22  void
      23  verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
      24  {
      25    CHECK_VALUE (result, NULL);
      26  
      27    /* Verify that the correct error message was emitted.  */
      28    CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
      29  		      "gcc_jit_context_new_field:"
      30  		      " unknown size for field \"f_opaque\" (type: struct opaque)");
      31  }