| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target analyzer } */ |
| 3 |
/* { dg-options "-fanalyzer" } */ |
| 4 |
/* { dg-require-python-h "" } */ |
| 5 |
|
| 6 |
|
| 7 |
#define PY_SSIZE_T_CLEAN |
| 8 |
#include <Python.h> |
| 9 |
#include "../analyzer/analyzer-decls.h" |
| 10 |
|
| 11 |
PyObject * |
| 12 |
test_PyList_New (Py_ssize_t len) |
| 13 |
{ |
| 14 |
PyObject *obj = PyList_New (len); |
| 15 |
if (obj) |
| 16 |
{ |
| 17 |
__analyzer_eval (obj->ob_refcnt == 1); /* { dg-warning "TRUE" } */ |
| 18 |
__analyzer_eval (PyList_CheckExact (obj)); /* { dg-warning "TRUE" } */ |
| 19 |
} |
| 20 |
else |
| 21 |
__analyzer_dump_path (); /* { dg-message "path" } */ |
| 22 |
return obj; |
| 23 |
} |
| 24 |
|
| 25 |
void |
| 26 |
test_PyList_New_2 () |
| 27 |
{ |
| 28 |
PyObject *obj = PyList_New (0); |
| 29 |
} /* { dg-warning "leak of 'obj'" } */ |
| 30 |
|
| 31 |
PyObject *test_stray_incref_PyList () |
| 32 |
{ |
| 33 |
PyObject *p = PyList_New (2); |
| 34 |
if (p) |
| 35 |
Py_INCREF (p); |
| 36 |
return p; |
| 37 |
/* { dg-warning "expected 'p' to have reference count" "" { target *-*-* } .-1 } */ |
| 38 |
} |