public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-8629] c++: deleted after first declaration [PR101106]
Date: Mon, 21 Jun 2021 20:42:48 +0000 (GMT)	[thread overview]
Message-ID: <20210621204248.093213861830@sourceware.org> (raw)

https://gcc.gnu.org/g:2348a458e156641c5d4b0e998ae0d175196cfd51

commit r11-8629-g2348a458e156641c5d4b0e998ae0d175196cfd51
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 17 15:31:15 2021 -0400

    c++: deleted after first declaration [PR101106]
    
    An explicitly deleted function must be deleted on its first declaration.  We
    were diagnosing this error only with -Wpedantic, but always giving the
    "previous declaration" note.  For GCC 11, keep the -Wpedantic dependency,
    just make the note depend on the previous diagnostic.
    
            PR c++/101106
    
    gcc/cp/ChangeLog:
    
            * decl.c (duplicate_decls): Condition note on return value of pedwarn.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/deleted15.C: New test.

Diff:
---
 gcc/cp/decl.c                          | 9 ++++-----
 gcc/testsuite/g++.dg/cpp0x/deleted15.C | 6 ++++++
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d2fc1c1d4a3..0ed15f53596 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2160,11 +2160,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden)
 	  if (DECL_DELETED_FN (newdecl))
 	    {
 	      auto_diagnostic_group d;
-	      pedwarn (newdecl_loc, OPT_Wpedantic,
-		       "deleted definition of %qD is not first declaration",
-		       newdecl);
-	      inform (olddecl_loc,
-		      "previous declaration of %qD", olddecl);
+	      if (pedwarn (newdecl_loc, OPT_Wpedantic, "deleted definition of "
+			   "%qD is not first declaration", newdecl))
+		inform (olddecl_loc,
+			"previous declaration of %qD", olddecl);
 	    }
 	  DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl);
 	}
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted15.C b/gcc/testsuite/g++.dg/cpp0x/deleted15.C
new file mode 100644
index 00000000000..ab1893d7e29
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/deleted15.C
@@ -0,0 +1,6 @@
+// PR c++/101106
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+int f();		// { dg-bogus "previous declaration" }
+int f() = delete;


                 reply	other threads:[~2021-06-21 20:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210621204248.093213861830@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.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).