re PR libstdc++/49058 ([C++0x] Bind no-arguments functor failed using std::bind with...
authorJason Merrill <jason@redhat.com>
Mon, 23 May 2011 15:32:39 +0000 (11:32 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 23 May 2011 15:32:39 +0000 (11:32 -0400)
PR c++/49058
* call.c (splice_viable): Be strict in templates.

From-SVN: r174073

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/sfinae24.C [new file with mode: 0644]

index 4b0b3a12946187388565f4d9d3b2f0e4f3418e89..cfb6b58065c46357ae1b7fad013555eb05c53c59 100644 (file)
@@ -1,5 +1,8 @@
 2011-05-23  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49058
+       * call.c (splice_viable): Be strict in templates.
+
        PR c++/47336
        * error.c (dump_template_bindings): Suppress access control.
 
index 972dca376eee61f397c323d4fe845458e3a796b9..8503f5ebabfb8fafbd9a0837d8d281048de363ca 100644 (file)
@@ -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;
index ac13fe55c3d010f846c605bb8555483e7432c534..c41c7f607533f6a090667c69745a35c5c9469326 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-23  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/sfinae24.C: New.
+
        * g++.dg/cpp0x/error3.C: New.
 
        * g++.dg/cpp0x/defaulted27.C: New.
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae24.C b/gcc/testsuite/g++.dg/cpp0x/sfinae24.C
new file mode 100644 (file)
index 0000000..3e1d2e7
--- /dev/null
@@ -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;
+}