public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Nathan Sidwell <nathan@acm.org>,
	gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ PATCH] Diagnose = delete override of a friend function defined earlier (PR c++/80259)
Date: Wed, 06 Dec 2017 22:37:00 -0000	[thread overview]
Message-ID: <CADzB+2kZERtWmPasY2TOE2MuQESiCjWnxecbRURLhAfD_bpTSQ@mail.gmail.com> (raw)
In-Reply-To: <20171202001349.GB2353@tucnak>

OK.

On Fri, Dec 1, 2017 at 7:13 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> As the testcase shows, we weren't diagnosing the foo case in the testcase
> and would just silently overwrite old DECL_INITIAL with error_mark_node
> and ICE later on.  Fixed thusly, bootstrapped/regtested on x86_64-linux
> and i686-linux, ok for trunk?
>
> 2017-12-01  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/80259
>         * decl2.c (grokfield): Diagnose = delete redefinition of a friend.
>
>         * g++.dg/cpp0x/pr80259.C: New test.
>
> --- gcc/cp/decl2.c.jj   2017-11-21 08:43:50.000000000 +0100
> +++ gcc/cp/decl2.c      2017-12-01 12:01:32.671514761 +0100
> @@ -911,9 +911,18 @@ grokfield (const cp_declarator *declarat
>         {
>           if (init == ridpointers[(int)RID_DELETE])
>             {
> -             DECL_DELETED_FN (value) = 1;
> -             DECL_DECLARED_INLINE_P (value) = 1;
> -             DECL_INITIAL (value) = error_mark_node;
> +             if (friendp && decl_defined_p (value))
> +               {
> +                 error ("redefinition of %q#D", value);
> +                 inform (DECL_SOURCE_LOCATION (value),
> +                         "%q#D previously defined here", value);
> +               }
> +             else
> +               {
> +                 DECL_DELETED_FN (value) = 1;
> +                 DECL_DECLARED_INLINE_P (value) = 1;
> +                 DECL_INITIAL (value) = error_mark_node;
> +               }
>             }
>           else if (init == ridpointers[(int)RID_DEFAULT])
>             {
> --- gcc/testsuite/g++.dg/cpp0x/pr80259.C.jj     2017-12-01 12:06:54.611405404 +0100
> +++ gcc/testsuite/g++.dg/cpp0x/pr80259.C        2017-12-01 12:06:19.000000000 +0100
> @@ -0,0 +1,13 @@
> +// PR c++/80259
> +// { dg-do compile { target c++11 } }
> +
> +void foo () {} // { dg-message "previously defined here" }
> +void bar ();
> +
> +struct A
> +{
> +  friend void foo () = delete; // { dg-error "redefinition of" }
> +  friend void bar () = delete; // { dg-message "previously defined here" }
> +};
> +
> +void bar () {} // { dg-error "redefinition of" }
>
>         Jakub

      reply	other threads:[~2017-12-06 22:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-02  0:13 Jakub Jelinek
2017-12-06 22:37 ` Jason Merrill [this message]

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=CADzB+2kZERtWmPasY2TOE2MuQESiCjWnxecbRURLhAfD_bpTSQ@mail.gmail.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=nathan@acm.org \
    /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).