(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
plugin/
diagnostic-test-paths-1.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-fdiagnostics-path-format=separate-events" } */
       3  
       4  #include <stddef.h>
       5  #include <stdlib.h>
       6  
       7  /* Minimal reimplementation of cpython API.  */
       8  typedef struct PyObject {} PyObject;
       9  extern int PyArg_ParseTuple (PyObject *args, const char *fmt, ...);
      10  extern PyObject *PyList_New (int);
      11  extern PyObject *PyLong_FromLong(long);
      12  extern void PyList_Append(PyObject *list, PyObject *item);
      13  
      14  PyObject *
      15  make_a_list_of_random_ints_badly(PyObject *self,
      16  				 PyObject *args)
      17  {
      18    PyObject *list, *item;
      19    long count, i;
      20  
      21    if (!PyArg_ParseTuple(args, "i", &count)) {
      22      return NULL;
      23    }
      24  
      25    list = PyList_New(0); /* { dg-line PyList_New } */
      26  	
      27    for (i = 0; i < count; i++) { /* { dg-line for } */
      28      item = PyLong_FromLong(random());
      29      PyList_Append(list, item); /* { dg-line PyList_Append } */
      30    }
      31    
      32    return list;
      33  
      34    /* { dg-error "passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter" "" { target *-*-* } PyList_Append } */
      35    /* { dg-message "\\(1\\) when 'PyList_New' fails, returning NULL" "" { target *-*-* } PyList_New } */
      36    /* { dg-message "\\(2\\) when 'i < count'" "" { target *-*-* } for } */
      37    /* { dg-message "\\(3\\) when calling 'PyList_Append', passing NULL from \\(1\\) as argument 1" "" { target *-*-* } PyList_Append } */
      38  }