public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: C++ PATCH for testsuite failures with -std=c++17
Date: Thu, 25 May 2017 09:23:00 -0000	[thread overview]
Message-ID: <20170525090813.GZ8499@tucnak> (raw)
In-Reply-To: <20170525085156.GY8499@tucnak>

On Thu, May 25, 2017 at 10:51:56AM +0200, Jakub Jelinek wrote:
> On Tue, May 09, 2017 at 04:37:16PM -0400, Jason Merrill wrote:
> > For C++17 aggregate bases, we have started adding base fields for
> > empty bases.  The code for calculating whether a class is standard
> > layout needs to ignore these.
> > 
> > The C++17 mode diagnostic for direct-enum-init1.C was incorrect.
> > 
> > Tested x86_64-pc-linux-gnu, applying to trunk.
> 
> > commit 9a612cc30d4b3ef905ce45304545d8b99a3cf5b9
> > Author: Jason Merrill <jason@redhat.com>
> > Date:   Tue May 9 14:15:38 2017 -0400
> > 
> >             * class.c (check_bases): Ignore empty bases.
> 
> This should have referenced PR c++/80605 (and is also a 7 regression).
> 
> > diff --git a/gcc/cp/class.c b/gcc/cp/class.c
> > index fc71766..085dbc3 100644
> > --- a/gcc/cp/class.c
> > +++ b/gcc/cp/class.c
> > @@ -1860,7 +1860,9 @@ check_bases (tree t,
> >  	       members */
> >  	    for (basefield = TYPE_FIELDS (basetype); basefield;
> >  		 basefield = DECL_CHAIN (basefield))
> > -	      if (TREE_CODE (basefield) == FIELD_DECL)
> > +	      if (TREE_CODE (basefield) == FIELD_DECL
> > +		  && DECL_SIZE (basefield)
> > +		  && !integer_zerop (DECL_SIZE (basefield)))
> 
> Is that what we really want?  I mean, shouldn't we at least also
> check that the basefield we want to ignore is DECL_ARTIFICIAL,
> or that it doesn't have DECL_NAME or something similar, to avoid
> considering user fields with zero size the same?
> I believe your change changes e.g.:
> struct S { int a[0]; };
> struct T : public S { int b[0]; int c; };
> bool q = __is_standard_layout (T);
> which previously e.g. with -std=gnu++14 emitted q = false, but
> now emits q = true.

We even have DECL_FIELD_IS_BASE macro, so can't the above be
  if (TREE_CODE (basefield) == FIELD_DECL
      && !DECL_FIELD_IS_BASE (basefield))
or
  if (TREE_CODE (basefield) == FIELD_DECL
      && (!DECL_FIELD_IS_BASE (basefield)
	  || (DECL_SIZE (basefield)
	      && !integer_zerop (DECL_SIZE (basefield)))))
or something similar?

	Jakub

  reply	other threads:[~2017-05-25  9:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09 20:42 Jason Merrill
2017-05-25  9:08 ` Jakub Jelinek
2017-05-25  9:23   ` Jakub Jelinek [this message]
2017-05-25 21:57     ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170525090813.GZ8499@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).