public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: jason@redhat.com, Patrick Palka <ppalka@redhat.com>
Subject: [PATCH 2/2] c++: duplicate "use of deleted fn" diagnostic [PR106880]
Date: Thu, 23 Mar 2023 17:18:03 -0400	[thread overview]
Message-ID: <20230323211803.396326-2-ppalka@redhat.com> (raw)
In-Reply-To: <20230323211803.396326-1-ppalka@redhat.com>

Here we're issuing a duplicate diagnostic for the use of the deleted
foo, first from the CALL_EXPR case of tsubst_copy_and_build (which
doesn't exit early upon failure), and again from from build_over_call
when rebuilding the substituted CALL_EXPR.

We can fix this by exiting early upon failure of the first call, but
this first call should always be redundant since build_over_call (or
another subroutine of finish_call_expr) ought to reliably call mark_used
for a suitable DECL_P callee anyway.

So this patch just gets rid of the first call to mark_used.

Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
trunk?

	PR c++/106880

gcc/cp/ChangeLog:

	* pt.cc (tsubst_copy_and_build) <case CALL_EXPR>: Don't call
	mark_used.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/deleted16.C: New test.
---
 gcc/cp/pt.cc                           |  6 ------
 gcc/testsuite/g++.dg/cpp0x/deleted16.C | 11 +++++++++++
 2 files changed, 11 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/deleted16.C

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 9b3cc33331c..060d2d38504 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -21176,12 +21176,6 @@ tsubst_copy_and_build (tree t,
 	      }
 	  }
 
-	/* Remember that there was a reference to this entity.  */
-	if (function != NULL_TREE
-	    && DECL_P (function)
-	    && !mark_used (function, complain) && !(complain & tf_error))
-	  RETURN (error_mark_node);
-
 	if (!maybe_fold_fn_template_args (function, complain))
 	  return error_mark_node;
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted16.C b/gcc/testsuite/g++.dg/cpp0x/deleted16.C
new file mode 100644
index 00000000000..93cfb51eb3d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/deleted16.C
@@ -0,0 +1,11 @@
+// PR c++/106880
+// Verify we don't emit a "use of deleted function" diagnostic twice.
+// { dg-do compile { target c++11 } }
+
+void foo() = delete;
+
+template<class T>
+void f(T t) { foo(t); } // { dg-bogus "deleted function.*deleted function" }
+                        // { dg-error "deleted function" "" { target *-*-*} .-1 }
+
+template void f(int);
-- 
2.40.0.130.g27d43aaaf5


  reply	other threads:[~2023-03-23 21:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 21:18 [PATCH 1/2] c++: improve "NTTP argument considered unused" fix [PR53164, PR105848] Patrick Palka
2023-03-23 21:18 ` Patrick Palka [this message]
2023-03-30  2:58   ` [PATCH 2/2] c++: duplicate "use of deleted fn" diagnostic [PR106880] Jason Merrill
2023-03-23 21:26 ` [PATCH 1/2] c++: improve "NTTP argument considered unused" fix [PR53164, PR105848] Patrick Palka
2023-03-27 13:30 ` Patrick Palka
2023-03-29 21:36   ` Jason Merrill
2023-03-30 18:53     ` Patrick Palka
2023-03-30 21:39       ` Jason Merrill
2023-03-31 15:25         ` Patrick Palka
2023-03-31 15:55           ` Patrick Palka
2023-03-31 17:28             ` Jason Merrill
2023-03-31 19:06               ` Patrick Palka
2023-04-01  3:50                 ` 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=20230323211803.396326-2-ppalka@redhat.com \
    --to=ppalka@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).