This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [commit] Do not rely on FIELD_LOC_KIND_BITPOS being zero
- From: Pedro Alves <palves at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: gdb-patches at sourceware dot org, Siddhesh Poyarekar <siddhesh at redhat dot com>
- Date: Tue, 17 Apr 2012 14:00:14 +0100
- Subject: Re: [commit] Do not rely on FIELD_LOC_KIND_BITPOS being zero
- References: <20120417124410.GA15356@host2.jankratochvil.net>
On 04/17/2012 01:44 PM, Jan Kratochvil wrote:
> Hi,
>
> FIELD_LOC_KIND_BITPOS is 0 and some code relied on it, using only
> TYPE_FIELD_BITPOS (type, n) = foo;
> instead of
> SET_FIELD_BITPOS (TYPE_FIELD (type, n), foo);
>
We could make the compiler catch these by making the macro return an rvalue.
---
gdb/gdbtypes.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 07c3a86..9901439 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1110,7 +1110,7 @@ extern void allocate_gnat_aux_type (struct type *);
#define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
#define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
#define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
-#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
+#define TYPE_FIELD_BITPOS(thistype, n) (FIELD_BITPOS (TYPE_FIELD (thistype, n)) + 0)
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
#define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n))