From patchwork Mon May 23 15:04:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 96970 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 2EDF5B6FAC for ; Tue, 24 May 2011 01:04:22 +1000 (EST) Received: (qmail 20700 invoked by alias); 23 May 2011 15:04:21 -0000 Received: (qmail 20692 invoked by uid 22791); 23 May 2011 15:04:20 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 May 2011 15:04:07 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4NF46rQ014601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 May 2011 11:04:06 -0400 Received: from [127.0.0.1] ([10.3.113.3]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4NF46Zr029148 for ; Mon, 23 May 2011 11:04:06 -0400 Message-ID: <4DDA7765.3030103@redhat.com> Date: Mon, 23 May 2011 11:04:05 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/49058 (different SFINAE with -pedantic) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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. commit b064aafb08a8c85cfb84c839e21cf704adb42b2d Author: Jason Merrill 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 T val(); + +struct F1 +{ + void operator()(); +}; + +template +struct Bind +{ + template()( ) )> + R f(); + + template()( ) )> + R f() const; // { dg-error "no match" } +}; + +int main() +{ + Bind b; +}