From patchwork Sun Jul 7 14:02:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Glisse X-Patchwork-Id: 257327 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4C1CC2C009A for ; Mon, 8 Jul 2013 00:02:50 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=aAEwGSNXpbX/mnhPf5Ev66L7StkeN6ylPXiln/z9UYyRMKyQer 3qN2FmfFVzm/7fnqcONwh1SMB1SK/ZauhCTZIc9ge7RZuhJ4ED28DOdwpOtQbXJC Y2/YIq3lYD3of6SAsbIouJ32w6Ys4Z+FZeUOKdG5yj860alXWNikI0opw= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=vv6tAAJUsP5uVePP4TuJhO2esM8=; b=P4Ghj3l0flvHxsVtTLP7 YYQsfZy7FJ0KJyETwacOKGujj4JAYVM6uXwdNx4i+zkgi6OTWRTAqRO7H2Fvosol HBPeUYbeu1FiAvxt/wBpwNE/9CisbfliuxurlpIOgzDTQl6hln00HRuU1MJYNL68 MqPy0nCjkNbwdpAAhDuMHOg= Received: (qmail 19991 invoked by alias); 7 Jul 2013 14:02:44 -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 19977 invoked by uid 89); 7 Jul 2013 14:02:43 -0000 X-Spam-SWARE-Status: No, score=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mail3-relais-sop.national.inria.fr (HELO mail3-relais-sop.national.inria.fr) (192.134.164.104) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 07 Jul 2013 14:02:42 +0000 Received: from stedding.saclay.inria.fr ([193.55.250.194]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 07 Jul 2013 16:02:40 +0200 Received: from glisse (helo=localhost) by stedding.saclay.inria.fr with local-esmtp (Exim 4.80) (envelope-from ) id 1UvpY0-0001S5-12; Sun, 07 Jul 2013 16:02:40 +0200 Date: Sun, 7 Jul 2013 16:02:40 +0200 (CEST) From: Marc Glisse To: gcc-patches@gcc.gnu.org cc: jason@redhat.com Subject: Preserve xvalues in ?: Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-Virus-Found: No Hello, this patch gets us one line closer to implementing the proper C++11 semantics for ?: (there are still quite a few missing). Bootstrap+testsuite on x86_64-unknown-linux-gnu. 2013-07-07 Marc Glisse PR c++/53000 gcc/cp/ * call.c (build_conditional_expr_1): Preserve xvalues. gcc/testsuite/ * g++.dg/cpp0x/decltype17.C: Adjust. Index: testsuite/g++.dg/cpp0x/decltype17.C =================================================================== --- testsuite/g++.dg/cpp0x/decltype17.C (revision 200742) +++ testsuite/g++.dg/cpp0x/decltype17.C (working copy) @@ -17,13 +17,13 @@ decltype(true ? lvalueref() : lvalueref( decltype(true ? rvalueref() : rvalueref()) h() {} int main() { if (strcmp (typeid(f).name(), "FivE") != 0) return 1; if (strcmp (typeid(g).name(), "FRivE") != 0) return 2; - if (strcmp (typeid(h).name(), "FivE") != 0) + if (strcmp (typeid(h).name(), "FOivE") != 0) return 3; } Index: cp/call.c =================================================================== --- cp/call.c (revision 200742) +++ cp/call.c (working copy) @@ -4634,24 +4634,25 @@ build_conditional_expr_1 (location_t loc && CLASS_TYPE_P (arg2_type) && cp_type_quals (arg2_type) != cp_type_quals (arg3_type)) arg2_type = arg3_type = cp_build_qualified_type (arg2_type, cp_type_quals (arg2_type) | cp_type_quals (arg3_type)); } /* [expr.cond] - If the second and third operands are lvalues and have the same - type, the result is of that type and is an lvalue. */ - if (real_lvalue_p (arg2) - && real_lvalue_p (arg3) + If the second and third operands are glvalues of the same value + category and have the same type, the result is of that type and + value category. */ + if (((real_lvalue_p (arg2) && real_lvalue_p (arg3)) + || (xvalue_p (arg2) && xvalue_p (arg3))) && same_type_p (arg2_type, arg3_type)) { result_type = arg2_type; arg2 = mark_lvalue_use (arg2); arg3 = mark_lvalue_use (arg3); goto valid_operands; } /* [expr.cond]