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