From patchwork Tue Feb 25 21:27:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 324103 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 29A052C00AC for ; Wed, 26 Feb 2014 08:27:43 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=KojB20HI/oN7jmua1PKKreTrXfHQEJsPqn4P1mbUZgB2sq thXAuDH5/2azHhkTwEQDUAs5VevOYs8jSF36A1thpxZFMwhBEKG4/ssff8aPkH8K x1tv+PVS9w5Vu5Q7zCkOkwv53yfX5B/1BNIpiOJvUa7KO8NF/OPCUq3VKyaGA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=6EyW8dJtkAAegmEHdhky8apAvWY=; b=PPmwg8wWjDFfkwN1+nkl iS3sM2SMmwaG7Pl7hlw8oidW4sC5u0mxMmUzI42jptdI8TvnyW5hzRmMcnOMRU95 W/CAvs1/gA98W9lwoXSu31z4U2HaW5GmfIsGxathG/IdJW4fAX3pjoiMbRZsp3oX v7pBO2cLBaF/z3iy+VbBUAg= Received: (qmail 18764 invoked by alias); 25 Feb 2014 21:27:36 -0000 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 Received: (qmail 18751 invoked by uid 89); 25 Feb 2014 21:27:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Feb 2014 21:27:33 +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 s1PLRWbY030449 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Feb 2014 16:27:32 -0500 Received: from [10.3.113.140] (ovpn-113-140.phx2.redhat.com [10.3.113.140]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1PLRVlg019752 for ; Tue, 25 Feb 2014 16:27:31 -0500 Message-ID: <530D0AC3.6030603@redhat.com> Date: Tue, 25 Feb 2014 16:27:31 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for DR 1571 (reference binding) Getting the reference binding rules for C++11 right (in the standard) has taken quite a few iterations. I'm pretty happy with the latest wording, which deals with user-defined conversions by recursing on the result of the conversion. This patch implements those rules. I'm a little uncertain about applying this so late in the 4.9 cycle, but I think it's a significant improvement to C++11 support. The second patch fixes a diagnostic issue I noticed while working on this: when explaining that a conversion from the result of the conversion function failed, the compiler was talking about the 'this' parameter. Tested x86_64-pc-linux-gnu, applying to trunk. commit f84d42ca81f6c327a0356a4dd426a68925db582b Author: Jason Merrill Date: Tue Feb 11 11:10:04 2014 -0800 * call.c (print_conversion_rejection): Handle n_arg of -2. (build_user_type_conversion_1): Pass it. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d3db585..700099d 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3180,6 +3180,10 @@ print_conversion_rejection (location_t loc, struct conversion_info *info) inform (loc, " no known conversion for implicit " "% parameter from %qT to %qT", info->from_type, info->to_type); + else if (info->n_arg == -2) + /* Conversion of conversion function return value failed. */ + inform (loc, " no known conversion from %qT to %qT", + info->from_type, info->to_type); else inform (loc, " no known conversion for argument %d from %qT to %qT", info->n_arg+1, info->from_type, info->to_type); @@ -3604,7 +3608,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags, if (!ics) { cand->viable = 0; - cand->reason = arg_conversion_rejection (NULL_TREE, -1, + cand->reason = arg_conversion_rejection (NULL_TREE, -2, rettype, totype); } else if (DECL_NONCONVERTING_P (cand->fn) @@ -3624,7 +3628,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags, { cand->viable = -1; cand->reason - = bad_arg_conversion_rejection (NULL_TREE, -1, + = bad_arg_conversion_rejection (NULL_TREE, -2, rettype, totype); } else if (primary_template_instantiation_p (cand->fn)