From patchwork Thu Nov 10 20:27:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 125001 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 303BC1007D1 for ; Fri, 11 Nov 2011 07:28:16 +1100 (EST) Received: (qmail 1103 invoked by alias); 10 Nov 2011 20:28:09 -0000 Received: (qmail 990 invoked by uid 22791); 10 Nov 2011 20:28:05 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Thu, 10 Nov 2011 20:27:48 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pAAKRm4w025293 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 10 Nov 2011 15:27:48 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pAAKRlep031434 for ; Thu, 10 Nov 2011 15:27:47 -0500 Received: from [0.0.0.0] (ovpn-113-127.phx2.redhat.com [10.3.113.127]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pAAKRkdl017217 for ; Thu, 10 Nov 2011 15:27:47 -0500 Message-ID: <4EBC33C1.1080800@redhat.com> Date: Thu, 10 Nov 2011 15:27:45 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20111001 Thunderbird/7.0.1 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/51079 (DR 495, checking second conv before template) 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 DR 495 changed the order of these rules. Tested x86_64-pc-linux-gnu, applying to trunk. commit dc49a72a22b10b39edc054414537bda44ce82546 Author: Jason Merrill Date: Thu Nov 10 14:59:15 2011 -0500 PR c++/51079, DR 495 * call.c (joust): Check the second conversion sequence before checking templates. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 578905e..e81950c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8109,6 +8109,22 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn) if (winner) return winner; + /* DR 495 moved this tiebreaker above the template ones. */ + /* or, if not that, + the context is an initialization by user-defined conversion (see + _dcl.init_ and _over.match.user_) and the standard conversion + sequence from the return type of F1 to the destination type (i.e., + the type of the entity being initialized) is a better conversion + sequence than the standard conversion sequence from the return type + of F2 to the destination type. */ + + if (cand1->second_conv) + { + winner = compare_ics (cand1->second_conv, cand2->second_conv); + if (winner) + return winner; + } + /* or, if not that, F1 is a non-template function and F2 is a template function specialization. */ @@ -8137,21 +8153,6 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn) return winner; } - /* or, if not that, - the context is an initialization by user-defined conversion (see - _dcl.init_ and _over.match.user_) and the standard conversion - sequence from the return type of F1 to the destination type (i.e., - the type of the entity being initialized) is a better conversion - sequence than the standard conversion sequence from the return type - of F2 to the destination type. */ - - if (cand1->second_conv) - { - winner = compare_ics (cand1->second_conv, cand2->second_conv); - if (winner) - return winner; - } - /* Check whether we can discard a builtin candidate, either because we have two identical ones or matching builtin and non-builtin candidates. diff --git a/gcc/testsuite/g++.dg/template/conv12.C b/gcc/testsuite/g++.dg/template/conv12.C new file mode 100644 index 0000000..e6af054 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/conv12.C @@ -0,0 +1,25 @@ +// PR c++/51079 + +#if __cplusplus > 199711L +struct C1 +{ + template + operator T() = delete; // { dg-message "declared here" "" { target c++11 } } + operator bool() { return false; } +} c1; + +int ic1 = c1; // { dg-error "deleted" "" { target c++11 } } +int ac1 = c1 + c1; // { dg-error "deleted" "" { target c++11 } } +#endif + +struct C2 +{ +private: + template + operator T(); // { dg-error "private" } +public: + operator bool() { return false; } +} c2; + +int ic2 = c2; // { dg-error "" } +int ac2 = c2 + c2; // { dg-error "" }