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 r13-5000] c++: mark_single_function and SFINAE [PR108282]
Date: Wed,  4 Jan 2023 19:13:21 +0000 (GMT)	[thread overview]
Message-ID: <20230104191321.710EE3858D35@sourceware.org> (raw)

https://gcc.gnu.org/g:238e292cf5d822f3bd12d9b58eb04cf377758b2a

commit r13-5000-g238e292cf5d822f3bd12d9b58eb04cf377758b2a
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jan 4 14:12:25 2023 -0500

    c++: mark_single_function and SFINAE [PR108282]
    
    We typically ignore mark_used failure when in a non-SFINAE context for
    sake of better error recovery.  But in mark_single_function we're
    instead ignoring mark_used failure in a SFINAE context, which ends up
    causing the second static_assert here to incorrectly fail.
    
            PR c++/108282
    
    gcc/cp/ChangeLog:
    
            * decl2.cc (mark_single_function): Ignore mark_used failure
            only in a non-SFINAE context rather than in a SFINAE one.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/concepts-requires34.C: New test.

Diff:
---
 gcc/cp/decl2.cc                                  |  2 +-
 gcc/testsuite/g++.dg/cpp2a/concepts-requires34.C | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index f95529a5c9a..00ed64d1691 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -5600,7 +5600,7 @@ mark_single_function (tree expr, tsubst_flags_t complain)
 
   if (is_overloaded_fn (expr) == 1
       && !mark_used (expr, complain)
-      && (complain & tf_error))
+      && !(complain & tf_error))
     return false;
   return true;
 }
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires34.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires34.C
new file mode 100644
index 00000000000..5bbd62f6d8e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires34.C
@@ -0,0 +1,19 @@
+// PR c++/108282
+// { dg-do compile { target c++20 } }
+
+template<class T>
+concept TEST = requires { T::TT; };
+
+struct C { };
+
+template<class AT>
+struct B {
+  static void TT() requires TEST<AT>;
+};
+
+int main() {
+  static_assert( !TEST<C> );
+  static_assert( !TEST<B<C>> );
+
+  B<C>::TT();  // { dg-error "no match" }
+}

                 reply	other threads:[~2023-01-04 19:13 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=20230104191321.710EE3858D35@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).