arm: fix typo in dg-require-effective-target [PR118089]
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / gil-1.c
blob6cbc1971b52bf2abf24ddc5971b5fc6bf5b2d80d
1 /* { dg-do compile } */
2 /* { dg-options "-fanalyzer" } */
3 /* { dg-require-effective-target analyzer } */
5 #include "gil.h"
7 void test_1 (void)
9 Py_BEGIN_ALLOW_THREADS
10 Py_END_ALLOW_THREADS
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" } */
18 Py_DECREF (obj);
20 Py_END_ALLOW_THREADS
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'" } */
28 Py_END_ALLOW_THREADS
30 Py_END_ALLOW_THREADS
33 void test_4 (PyObject *obj)
35 /* These aren't nested, so should be OK. */
36 Py_BEGIN_ALLOW_THREADS
37 Py_END_ALLOW_THREADS
39 Py_BEGIN_ALLOW_THREADS
40 Py_END_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'" } */
49 Py_END_ALLOW_THREADS
52 void test_5 (PyObject *obj)
54 Py_BEGIN_ALLOW_THREADS /* { dg-message "releasing the GIL here" } */
55 called_by_test_5 ();
56 Py_END_ALLOW_THREADS
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" } */
65 Py_DECREF (obj);
68 void test_6 (PyObject *obj)
70 Py_BEGIN_ALLOW_THREADS /* { dg-message "releasing the GIL here" } */
71 called_by_test_6 (obj);
72 Py_END_ALLOW_THREADS
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" } */
81 Py_END_ALLOW_THREADS
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" } */
90 Py_END_ALLOW_THREADS