Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/refcounting-1.c

raw
1 #include "analyzer-decls.h"
2
3 typedef struct obj {
4 int ob_refcnt;
5 } PyObject;
6
7 extern void Py_Dealloc (PyObject *op);
8
9 #define Py_INCREF(op) \
10 do { \
11 ((PyObject*)(op))->ob_refcnt++; \
12 } while (0)
13
14 #define Py_DECREF(op) \
15 do { \
16 if (--((PyObject*)(op))->ob_refcnt == 0) \
17 { \
18 /*Py_Dealloc((PyObject *)(op));*/ \
19 } \
20 } while (0)
21
22 void test_1 (PyObject *obj)
23 {
24 int orig_refcnt = obj->ob_refcnt;
25 Py_INCREF (obj);
26 Py_INCREF (obj);
27 Py_DECREF (obj);
28 Py_INCREF (obj);
29 __analyzer_eval (obj->ob_refcnt == orig_refcnt + 2); /* { dg-warning "TRUE" } */
30 }
31 /* TODO: uncomment the Py_Dealloc, which leads to two paths. */