public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix build with GCC 7.5
@ 2023-11-22 14:03 Tom Tromey
  2023-11-22 14:27 ` Tom de Vries
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2023-11-22 14:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom de Vries, Tom Tromey

A recent change to 'struct field' caused a build failure with GCC
7.5.0, as reported by Tom de Vries:

/data/vries/gdb/src/gdb/gdbtypes.h:721:51: error:
‘field::m_accessibility’ is too small to hold all values of ‘enum
class accessibility’ [-Werror]
   ENUM_BITFIELD (accessibility) m_accessibility : 2;
                                                   ^

Mark Wielaard pointed out that this was a GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242

This patch works around the bug by changing this member not to be a
bitfield.  It reduces the size of the enum a bit instead.  I also
changed m_bitsize to no longer be a bitfield -- that was done for
packing reasons in ancient times, but with m_accessibility not being a
bitfield, this no longer matters.

This patch does not change the size of struct field on 64-bit hosts.
---
 gdb/gdbtypes.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 34ca1ac99e5..411916e7b3f 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -534,7 +534,7 @@ union field_location
 };
 
 /* Accessibility of a member.  */
-enum class accessibility : unsigned
+enum class accessibility : unsigned char
 {
   /* It's important that this be 0 so that fields default to
      public.  */
@@ -717,8 +717,6 @@ struct field
 
   unsigned int m_artificial : 1;
 
-  /* Accessibility of the field.  */
-  ENUM_BITFIELD (accessibility) m_accessibility : 2;
   /* Whether the field is 'virtual'.  */
   bool m_virtual : 1;
   /* Whether the field is 'ignored'.  */
@@ -728,13 +726,16 @@ struct field
 
   ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3;
 
+  /* Accessibility of the field.  */
+  enum accessibility m_accessibility;
+
   /* * Size of this field, in bits, or zero if not packed.
      If non-zero in an array type, indicates the element size in
      bits (used only in Ada at the moment).
      For an unpacked field, the field's type's length
      says how many bytes the field occupies.  */
 
-  unsigned int m_bitsize : 28;
+  unsigned int m_bitsize;
 
   /* * In a struct or union type, type of this field.
      - In a function or member type, type of this argument.
-- 
2.41.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-22 17:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22 14:03 [PATCH] Fix build with GCC 7.5 Tom Tromey
2023-11-22 14:27 ` Tom de Vries
2023-11-22 15:17   ` Tom Tromey
2023-11-22 17:04     ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).