public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/49058 (different SFINAE with -pedantic)
Date: Mon, 23 May 2011 15:48:00 -0000	[thread overview]
Message-ID: <4DDA7765.3030103@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 424 bytes --]

Normally, we try to be somewhat permissive about overload resolution, 
accepting near-matches when available in order to give better 
diagnostics about why they aren't complete matches.  But this doesn't 
apply in templates, since we don't actually perform the conversions that 
would generate the diagnostics, and in SFINAE context it's important to 
be strictly conforming.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 49058.patch --]
[-- Type: text/x-patch, Size: 1418 bytes --]

commit b064aafb08a8c85cfb84c839e21cf704adb42b2d
Author: Jason Merrill <jason@redhat.com>
Date:   Sun May 22 22:18:07 2011 -0400

    	PR c++/49058
    	* call.c (splice_viable): Be strict in templates.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 972dca3..8503f5e 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3009,6 +3009,11 @@ splice_viable (struct z_candidate *cands,
   struct z_candidate **last_viable;
   struct z_candidate **cand;
 
+  /* Be strict inside templates, since build_over_call won't actually
+     do the conversions to get pedwarns.  */
+  if (processing_template_decl)
+    strict_p = true;
+
   viable = NULL;
   last_viable = &viable;
   *any_viable_p = false;
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae24.C b/gcc/testsuite/g++.dg/cpp0x/sfinae24.C
new file mode 100644
index 0000000..3e1d2e7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae24.C
@@ -0,0 +1,29 @@
+// PR c++/49058
+// This error is not subject to SFINAE because it doesn't happen in the
+// deduction context.
+// { dg-options -std=c++0x }
+// { dg-prune-output "note" }
+
+template<typename T> T val();
+
+struct F1
+{
+    void operator()();
+};
+
+template<typename F>
+struct Bind
+{
+    template<typename R
+      = decltype( val<F>()( ) )>
+    R f();
+
+    template<typename R
+      = decltype( val<const F>()( ) )>
+    R f() const;		// { dg-error "no match" }
+};
+
+int main()
+{
+  Bind<F1> b;
+}

                 reply	other threads:[~2011-05-23 15:04 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=4DDA7765.3030103@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@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).