(root)/
gcc-13.2.0/
gcc/
testsuite/
jit.dg/
test-error-new-binary-op-bad-op.c
       1  #include <stdlib.h>
       2  #include <stdio.h>
       3  
       4  #include "libgccjit.h"
       5  
       6  #include "harness.h"
       7  
       8  void
       9  create_code (gcc_jit_context *ctxt, void *user_data)
      10  {
      11    /* Trigger an API error by passing bad data.  */
      12    (void)gcc_jit_context_new_binary_op (
      13  	  ctxt,
      14  	  NULL,
      15  
      16  	  /* Non-valid enum value: */
      17  	  (enum gcc_jit_binary_op) 42,
      18  
      19  	  /* These aren't valid either: */
      20  	  NULL, /* gcc_jit_type *result_type, */
      21  	  NULL, NULL); /* gcc_jit_rvalue *a, gcc_jit_rvalue *b */
      22  
      23  }
      24  
      25  void
      26  verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
      27  {
      28    /* Ensure that the bad API usage prevents the API giving a bogus
      29       result back.  */
      30    CHECK_VALUE (result, NULL);
      31  
      32    /* Verify that the correct error message was emitted.  */
      33    CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
      34  		      ("gcc_jit_context_new_binary_op:"
      35  		       " unrecognized value for enum gcc_jit_binary_op: 42"));
      36  }
      37