Re: [commit] Do not rely on FIELD_LOC_KIND_BITPOS being zero

Pedro Alves
2012-04-17T13:00:35Z

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))