(root)/
gcc-13.2.0/
gcc/
testsuite/
jit.dg/
test-error-missing-return.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    /* Let's try to inject the equivalent of:
      12         int
      13         test_fn ()
      14         {
      15         }
      16       and verify that the API complains about the lack of
      17       a returned value.
      18    */
      19    gcc_jit_type *int_type =
      20      gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT);
      21  
      22    (void)gcc_jit_context_new_function (ctxt, NULL,
      23  				      GCC_JIT_FUNCTION_EXPORTED,
      24  				      int_type,
      25  				      "test_fn",
      26  				      0, NULL,
      27  				      0);
      28  }
      29  
      30  void
      31  verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
      32  {
      33    CHECK_VALUE (result, NULL);
      34  
      35    /* Verify that the correct error message was emitted.  */
      36    CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt),
      37  		      "function test_fn returns non-void (type: int)"
      38  		      " but has no blocks");
      39  }
      40