1 /* { dg-do compile } */
2 /* { dg-options "-fanalyzer" } */
3 /* { dg-require-effective-target analyzer } */
13 void test_2 (PyObject
*obj
)
15 Py_BEGIN_ALLOW_THREADS
/* { dg-message "releasing the GIL here" } */
17 Py_INCREF (obj
); /* { dg-warning "use of PyObject '\\*obj' without the GIL" } */
23 void test_3 (PyObject
*obj
)
25 Py_BEGIN_ALLOW_THREADS
/* { dg-message "releasing the GIL here" } */
27 Py_BEGIN_ALLOW_THREADS
/* { dg-warning "nested usage of 'Py_BEGIN_ALLOW_THREADS'" } */
33 void test_4 (PyObject
*obj
)
35 /* These aren't nested, so should be OK. */
36 Py_BEGIN_ALLOW_THREADS
39 Py_BEGIN_ALLOW_THREADS
43 /* Interprocedural example of erroneously nested usage. */
45 static void __attribute__((noinline
))
46 called_by_test_5 (void)
48 Py_BEGIN_ALLOW_THREADS
/* { dg-warning "nested usage of 'Py_BEGIN_ALLOW_THREADS'" } */
52 void test_5 (PyObject
*obj
)
54 Py_BEGIN_ALLOW_THREADS
/* { dg-message "releasing the GIL here" } */
59 /* Interprocedural example of bogusly using a PyObject outside of GIL. */
61 static void __attribute__((noinline
))
62 called_by_test_6 (PyObject
*obj
)
64 Py_INCREF (obj
); /* { dg-warning "use of PyObject '\\*obj' without the GIL" } */
68 void test_6 (PyObject
*obj
)
70 Py_BEGIN_ALLOW_THREADS
/* { dg-message "releasing the GIL here" } */
71 called_by_test_6 (obj
);
75 extern void called_by_test_7 (PyObject
*obj
);
77 void test_7 (PyObject
*obj
)
79 Py_BEGIN_ALLOW_THREADS
/* { dg-message "releasing the GIL here" } */
80 called_by_test_7 (obj
); /* { dg-warning "use of PyObject as argument 1 of 'called_by_test_7' without the GIL" } */
84 typedef void (*callback_t
) (PyObject
*);
86 void test_8 (PyObject
*obj
, callback_t cb
)
88 Py_BEGIN_ALLOW_THREADS
/* { dg-message "releasing the GIL here" } */
89 cb (obj
); /* { dg-warning "use of PyObject as argument 1 of call without the GIL" } */