aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python-internal.h
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-05-21 20:52:30 +0000
committerPedro Alves <palves@redhat.com>2013-05-21 20:52:30 +0000
commit1915daebe6683fb1cdd42c87a6db5532a396bbc6 (patch)
treebfa6dede3c6bd8ed9c72fce2ae57e1b8ce4046b7 /gdb/python/python-internal.h
parent52c935b6f53a31185e201524b479e18f3b925981 (diff)
downloadfsf-binutils-gdb-1915daebe6683fb1cdd42c87a6db5532a396bbc6.zip
fsf-binutils-gdb-1915daebe6683fb1cdd42c87a6db5532a396bbc6.tar.gz
fsf-binutils-gdb-1915daebe6683fb1cdd42c87a6db5532a396bbc6.tar.bz2
Centralize workaround for Python 2.6's Py_DECREF.
Wrap/redefine Py_DECREF ourselves, avoiding the need for uses to care about extra braces due to the fact that Python only started wrapping Py_DECREF in 'do {} while (0)' after 2.6. gdb/ 2013-05-21 Pedro Alves <palves@redhat.com> * python/py-utils.c (py_decref): Remove extra braces. (gdb_pymodule_addobject): Remove extra braces. * python-internal.h (gdb_Py_DECREF): New static inline function. (Py_DECREF): Redefine as calling gdb_Py_DECREF.
Diffstat (limited to 'gdb/python/python-internal.h')
-rw-r--r--gdb/python/python-internal.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index b01efa1..b5c34b6 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -169,6 +169,18 @@ typedef unsigned long gdb_py_ulongest;
#endif /* HAVE_LONG_LONG */
+/* Python 2.6 did not wrap Py_DECREF in 'do {...} while (0)', leading
+ to 'suggest explicit braces to avoid ambiguous ‘else’' gcc errors.
+ Wrap it ourselves, so that callers don't need to care. */
+
+static inline void
+gdb_Py_DECREF (void *op)
+{
+ Py_DECREF (op);
+}
+
+#undef Py_DECREF
+#define Py_DECREF(op) gdb_Py_DECREF (op)
/* In order to be able to parse symtab_and_line_to_sal_object function
a real symtab_and_line structure is needed. */