On Wed, Sep 01, 2021 at 05:32:07PM -0400, Jason Merrill wrote:
> On 8/31/21 5:15 AM, Richard Biener wrote:
> > On Tue, 31 Aug 2021, Jakub Jelinek wrote:
> > 
> > > On Tue, Aug 31, 2021 at 09:57:44AM +0200, Richard Biener wrote:
> > > > Just to clarify - in the C++ FE these fields are meaningful for
> > > > layout purposes but they are only supposed to influence layout
> > > > but not ABI (but why does the C++ FE say that?)
> 
> The code to remove zero-length bit-fields was copied from the C front end
> when G++ was first created.  It was removed from the C front end by Joseph's
> r84279.  The last thread for that patch is
> 
> https://gcc.gnu.org/pipermail/gcc-patches/2004-July/thread.html#142984
> 
> The patch and that thread contain no discussion of zero-length bit-fields,
> nor is there one in any of the testcases added by the patch.
> 
> I guess the assumption both before and after that patch was that zero-length
> bit-fields would not affect ABI, whether or not they appeared in
> TYPE_FIELDS.  Are the targets where ABI is affected all new since then?

Ah, thanks for the archeology.  So it indeed seems like in theory an ABI change
between GCC 3.4 and 4.0 for C then on some of the targets like x86_64 which
already existed in 3.2-ish era.  I actually couldn't see a difference
between C and C++ in that era on x86_64, e.g. 3.3 C and C++ both work as
C and C++ now, as if the zero width bitfields aren't removed.
Before the PR42217 fix the C++ FE wasn't really removing the zero width 
bitfields
properly, so it is actually 4.5/4.4-ish regression for C++.

> > Anyway, I'm not stuck to whatever naming we choose but the situation
> > is complicated enough that we want some more elaborate docs in tree.h
> > I'll leave the final ACK to Jason (unless he's on vacation).
> 
> DECL_FIELD_FOR_LAYOUT sounds better to me.

Just for the zero-width bitfields, or also for the class FIELD_DECLs on
which we set DECL_FIELD_ABI_IGNORED now?
I could e.g. keep DECL_FIELD_ABI_IGNORED for the class ones, by
making
#define DECL_FIELD_ABI_IGNORED(field) \
  (!DECL_BIT_FIELD (field) && (FIELD_DECL_CHECK 
(NODE)->decl_common.decl_flag_0))
add SET_DECL_FIELD_ABI_IGNORED macro and similarly define
DECL_FIELD_FOR_LAYOUT and SET_DECL_FIELD_FOR_LAYOUT (just it would do
DECL_BIT_FIELD (field) check in that case).

        Jakub

Reply via email to