From patchwork Mon Sep 5 04:29:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 113304 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 E25E0B6F71 for ; Mon, 5 Sep 2011 14:29:37 +1000 (EST) Received: (qmail 14861 invoked by alias); 5 Sep 2011 04:29:32 -0000 Received: (qmail 14852 invoked by uid 22791); 5 Sep 2011 04:29:30 -0000 X-SWARE-Spam-Status: No, hits=-6.7 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; Mon, 05 Sep 2011 04:29:10 +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 p854TAY4009601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 5 Sep 2011 00:29:10 -0400 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 p854T95U032303 for ; Mon, 5 Sep 2011 00:29:09 -0400 Received: from [0.0.0.0] (ovpn-113-26.phx2.redhat.com [10.3.113.26]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p854T8QP000661 for ; Mon, 5 Sep 2011 00:29:08 -0400 Message-ID: <4E645014.70508@redhat.com> Date: Mon, 05 Sep 2011 00:29:08 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0) Gecko/20110817 Thunderbird/6.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCHes for DR 1328, c++/49267, c++/49458 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 These two PRs have to do with comparing conversion operators that return lvalue or rvalue references. The fix for 49458 is to consider that directly when deciding whether the rvalueness matches the target reference, before an rvalue reference to function has decayed to an lvalue. Part of this fixes 49267, but I've also fixed (in the second patch) the code that incorrectly decided that an rvalue reference to int was an lvalue. Tested x86_64-pc-linux-gnu, applying to trunk. Also applying the compare_ics hunk to 4.6. commit 41e2f64d32ca6f850f2907387285ad0d37e93a25 Author: Jason Merrill Date: Wed Aug 31 16:49:33 2011 -0400 * call.c (reference_binding): Don't set is_lvalue for an rvalue reference rfrom. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 1fa5fc8..c707d66 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1576,9 +1576,10 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) if (TREE_CODE (from) == REFERENCE_TYPE) { - /* Anything with reference type is an lvalue. */ - is_lvalue = clk_ordinary; from = TREE_TYPE (from); + if (!TYPE_REF_IS_RVALUE (rfrom) + || TREE_CODE (from) == FUNCTION_TYPE) + is_lvalue = clk_ordinary; } if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr))