public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/49058 (different SFINAE with -pedantic)
@ 2011-05-23 15:48 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2011-05-23 15:48 UTC (permalink / raw)
  To: gcc-patches List

[-- 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;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-23 15:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23 15:48 C++ PATCH for c++/49058 (different SFINAE with -pedantic) Jason Merrill

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).