public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9066] c++: compound-requirement partial substitution [PR113966]
Date: Mon, 19 Feb 2024 16:35:32 +0000 (GMT)	[thread overview]
Message-ID: <20240219163532.3BC413858C2F@sourceware.org> (raw)

https://gcc.gnu.org/g:3a6f3354eaaf38b5e6be41e4ebf521d299593a6e

commit r14-9066-g3a6f3354eaaf38b5e6be41e4ebf521d299593a6e
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Feb 19 11:34:45 2024 -0500

    c++: compound-requirement partial substitution [PR113966]
    
    When partially substituting a requires-expr, we don't want to perform
    any additional checks beyond the substitution itself so as to minimize
    checking requirements out of order.  So don't check the return-type-req
    of a compound-requirement during partial substitution.  And don't check
    the noexcept condition either since we can't do that on templated trees.
    
            PR c++/113966
    
    gcc/cp/ChangeLog:
    
            * constraint.cc (tsubst_compound_requirement): Don't check
            the noexcept condition or the return-type-requirement when
            partially substituting.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/concepts-friend17.C: New test.
    
    Reviewed-by: Jason Merrill <jason@redhat.com>

Diff:
---
 gcc/cp/constraint.cc                           |  5 +++--
 gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index d9569013bd34..49de3211d4c7 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2134,7 +2134,8 @@ tsubst_compound_requirement (tree t, tree args, sat_info info)
 
   /* Check the noexcept condition.  */
   bool noexcept_p = COMPOUND_REQ_NOEXCEPT_P (t);
-  if (noexcept_p && !expr_noexcept_p (expr, quiet.complain))
+  if (noexcept_p && !processing_template_decl
+      && !expr_noexcept_p (expr, quiet.complain))
     {
       if (info.diagnose_unsatisfaction_p ())
 	inform (loc, "%qE is not %<noexcept%>", expr);
@@ -2148,7 +2149,7 @@ tsubst_compound_requirement (tree t, tree args, sat_info info)
     return error_mark_node;
 
   /* Check expression against the result type.  */
-  if (type)
+  if (type && !processing_template_decl)
     {
       if (tree placeholder = type_uses_auto (type))
 	{
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C b/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C
new file mode 100644
index 000000000000..9b5091f14a81
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-friend17.C
@@ -0,0 +1,15 @@
+// PR c++/113966
+// { dg-do compile { target c++20 } }
+
+template<class T> concept C = T::value;
+
+template<class T>
+struct A {
+  template<class U> requires U::value || requires { { T() } -> C; }
+  friend void f(A, U) { }
+
+  template<class U> requires requires { { g(U()) } noexcept; }
+  friend void f(A, U, U) { }
+};
+
+template struct A<int>;

                 reply	other threads:[~2024-02-19 16:35 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=20240219163532.3BC413858C2F@sourceware.org \
    --to=ppalka@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).