1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-format=json" } */
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
);
15 make_a_list_of_random_ints_badly(PyObject
*self
,
18 PyObject
*list
, *item
;
21 if (!PyArg_ParseTuple(args
, "i", &count
)) {
27 for (i
= 0; i
< count
; i
++) {
28 item
= PyLong_FromLong(random());
29 PyList_Append(list
, item
);
35 /* { dg-begin-multiline-output "" }
37 "message": "passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter",
40 "locations": [{"caret": {"file": "
50 "path": [{"location": {"file": "
55 "description": "when 'PyList_New' fails, returning NULL",
56 "function": "make_a_list_of_random_ints_badly",
58 {"location": {"file": "
63 "description": "when 'i < count'",
64 "function": "make_a_list_of_random_ints_badly",
66 {"location": {"file": "
71 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
72 "function": "make_a_list_of_random_ints_badly",
74 "escape-source": false}]
75 { dg-end-multiline-output "" } */