public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Christophe Lyon <christophe.lyon@linaro.org>
To: Jason Merrill <jason@redhat.com>
Cc: Alexandre Oliva <aoliva@redhat.com>,
	gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] [PR c++/88146] do not crash synthesizing inherited ctor(...)
Date: Wed, 19 Dec 2018 14:36:00 -0000	[thread overview]
Message-ID: <CAKdteObB7iAgtvKsuN5pXpxpoBszbxkw_yJuvNd-K0HLE7-34A@mail.gmail.com> (raw)
In-Reply-To: <CADzB+2kNPc+gcPgjvAFc7wzAzcmd3JuZ+D3geaMOKsfWm4b3Jg@mail.gmail.com>

On Sat, 15 Dec 2018 at 23:11, Jason Merrill <jason@redhat.com> wrote:
>
> On Fri, Dec 14, 2018 at 6:05 PM Alexandre Oliva <aoliva@redhat.com> wrote:
> >
> > On Dec 14, 2018, Jason Merrill <jason@redhat.com> wrote:
> >
> > > Let's move the initialization of "fields" inside the 'then' block here
> > > with the initialization of "cvquals", rather than clear it in the
> > > 'else'.
> >
> > We'd still have to NULL-initialize it somewhere, so I'd rather just move
> > the entire loop into the conditional, and narrow the scope of variables
> > only used within the loop, like this.  The full patch below is very hard
> > to read because of the reindentation, so here's a diff -b.
> >
> > diff --git a/gcc/cp/method.c b/gcc/cp/method.c
> > index fd023e200538..17404a65b0fd 100644
> > --- a/gcc/cp/method.c
> > +++ b/gcc/cp/method.c
> > @@ -675,12 +675,9 @@ do_build_copy_constructor (tree fndecl)
> >      }
> >    else
> >      {
> > -      tree fields = TYPE_FIELDS (current_class_type);
> >        tree member_init_list = NULL_TREE;
> > -      int cvquals = cp_type_quals (TREE_TYPE (parm));
> >        int i;
> >        tree binfo, base_binfo;
> > -      tree init;
> >        vec<tree, va_gc> *vbases;
> >
> >        /* Initialize all the base-classes with the parameter converted
> > @@ -704,15 +701,18 @@ do_build_copy_constructor (tree fndecl)
> >                                                 inh, member_init_list);
> >         }
> >
> > -      for (; fields; fields = DECL_CHAIN (fields))
> > +      if (!inh)
> > +       {
> > +         int cvquals = cp_type_quals (TREE_TYPE (parm));
> > +
> > +         for (tree fields = TYPE_FIELDS (current_class_type);
> > +              fields; fields = DECL_CHAIN (fields))
> >             {
> >               tree field = fields;
> >               tree expr_type;
> >
> >               if (TREE_CODE (field) != FIELD_DECL)
> >                 continue;
> > -         if (inh)
> > -           continue;
> >
> >               expr_type = TREE_TYPE (field);
> >               if (DECL_NAME (field))
> > @@ -742,7 +742,7 @@ do_build_copy_constructor (tree fndecl)
> >                   expr_type = cp_build_qualified_type (expr_type, quals);
> >                 }
> >
> > -         init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE);
> > +             tree init = build3 (COMPONENT_REF, expr_type, parm, field, NULL_TREE);
> >               if (move_p && !TYPE_REF_P (expr_type)
> >                   /* 'move' breaks bit-fields, and has no effect for scalars.  */
> >                   && !scalarish_type_p (expr_type))
> > @@ -751,6 +751,8 @@ do_build_copy_constructor (tree fndecl)
> >
> >               member_init_list = tree_cons (field, init, member_init_list);
> >             }
> > +       }
> > +
> >        finish_mem_initializers (member_init_list);
> >      }
> >  }
> > @@ -891,6 +893,7 @@ synthesize_method (tree fndecl)
> >
> >    /* Reset the source location, we might have been previously
> >       deferred, and thus have saved where we were first needed.  */
> > +  if (!DECL_INHERITED_CTOR (fndecl))
> >      DECL_SOURCE_LOCATION (fndecl)
> >        = DECL_SOURCE_LOCATION (TYPE_NAME (DECL_CONTEXT (fndecl)));
> >
> >
> > Is this OK too?  (pending regstrapping)
>
> Yes, thanks.
>

Hi,

The new test inh-ctor32.C fails on arm:
FAIL:    g++.dg/cpp0x/inh-ctor32.C  -std=c++14  (test for warnings, line 208)
FAIL:    g++.dg/cpp0x/inh-ctor32.C  -std=c++17  (test for warnings, line 208)

The log has:

/gcc/testsuite/g++.dg/cpp0x/inh-ctor32.C: In instantiation of
'constexpr derived_ctor::inherited_derived_ctor::constexpr_noninherited_ctor::bor::bor(T
...) [with T = {int, int}]':
/gcc/testsuite/g++.dg/cpp0x/inh-ctor32.C:206:13:   required from
'constexpr derived_ctor::inherited_derived_ctor::constexpr_noninherited_ctor::bar::bar(T
...) [with T = {int, int}][inherited from
derived_ctor::inherited_derived_ctor::constexpr_noninherited_ctor::bor]'
/gcc/testsuite/g++.dg/cpp0x/inh-ctor32.C:208:42:   required from here

Christophe


> Jason

  reply	other threads:[~2018-12-19 14:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-07  0:23 Alexandre Oliva
2018-12-14 20:14 ` Alexandre Oliva
2018-12-14 20:42 ` Jason Merrill
2018-12-14 21:41   ` Jason Merrill
2018-12-14 22:34     ` Alexandre Oliva
2018-12-14 22:44       ` Jason Merrill
2018-12-14 23:05         ` Alexandre Oliva
2018-12-15 22:11           ` Jason Merrill
2018-12-19 14:36             ` Christophe Lyon [this message]
2018-12-19 18:49               ` Alexandre Oliva
2018-12-19 18:52                 ` Jakub Jelinek
2018-12-20  0:04               ` Alexandre Oliva
2018-12-20 16:00                 ` Christophe Lyon
2018-12-20 16:18                 ` Jason Merrill
2018-12-28 22:53                   ` Alexandre Oliva
2018-12-29  6:40                     ` Alexandre Oliva
2018-12-29 13:33                       ` Jakub Jelinek
2019-01-04 18:55                       ` Jason Merrill
2019-01-17  4:12                         ` Alexandre Oliva
2018-12-29 10:28                     ` Alexandre Oliva

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=CAKdteObB7iAgtvKsuN5pXpxpoBszbxkw_yJuvNd-K0HLE7-34A@mail.gmail.com \
    --to=christophe.lyon@linaro.org \
    --cc=aoliva@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).