From patchwork Sun Nov 13 06:48:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 694087 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 3tGklF1Rqwz9t0Z for ; Sun, 13 Nov 2016 17:48:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="LTpYaBu2"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=UK/EQxdPk6S/2lxiCu6++4d1HnG9wG3oJ8+NFd9Qt/7pg/ 5haLPfDagxcSWTTv+4TScVebmsnQGzrqTyDZuuWAHJiKe4JfKq+ie/ZchiK9P+1T RDUid86qBXdPOeybhwA6744tMRyPq9jyLo9h/hjIIlz/poufIqv/63/aCHYHg= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=vWjuJQy4+RIkeUMCLy8OuHITSSo=; b=LTpYaBu2XR7ABVI+wNkJ upHYon/U6Vo4dqlicG7KsMU3zmHLkJFDaHMrTq3yKCR+wl1LqVyOx6z4GagB1nk2 K9zwEb/Q2tKosIpiOq7gbRDmZ+F+ckoV23/hnZ6RgA7ZrgBTSon0OCQRnrlwUt2f vWYZHzLYTsMwWl+keVRAYmo= Received: (qmail 42336 invoked by alias); 13 Nov 2016 06:48:39 -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 42182 invoked by uid 89); 13 Nov 2016 06:48:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*F:U*jason, Hx-languages-length:1410, UD:constexpr.c, constexpr.c X-HELO: mail-oi0-f45.google.com Received: from mail-oi0-f45.google.com (HELO mail-oi0-f45.google.com) (209.85.218.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 13 Nov 2016 06:48:25 +0000 Received: by mail-oi0-f45.google.com with SMTP id 128so29384463oih.0 for ; Sat, 12 Nov 2016 22:48:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=oEPJ8y4iwusEa7VtwJBspq6axD8AxX00JCkDZHOqbhU=; b=lrAhiy5T1APwyD4QQPqoD5PCycgLXcn6VnIx1u4vt5bzdbGygCz573vBzgk3LMl/NK KrbX+JfvVml2n1LTKAeMHYb/6bL8csOog4CtC0150htQ4uXeQCIwdfrZQkTrXXe2jiZs I6c7emDiWLgUtzmGHqsGLidIJDmTcg3OcGwv7+w/MgZDDVRG8/SGw6TA6ztt4qDRweIM eRJHn4FJjaXH5FCqTwRqyfLOLLEpXftxCnO6MU7COnfkyu4wMGJm0vMWbzT1fV0g9bCK TBEWbqHTvL0Ug1qoEe/zV1EXc6A/nyWxKYp9AtK7gPgz+h+tdkTGCHHcbWUDK2ZLisOk RZSw== X-Gm-Message-State: ABUngvfCIHRpJWwnkeoPetlUg5X74KzR8z4SzeWuLNT8CX+qq80hH2au43o4LjNq3g9u6oVrtyrpM3fXXSWtpBNW X-Received: by 10.202.114.129 with SMTP id p123mr6091121oic.132.1479019703802; Sat, 12 Nov 2016 22:48:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.153.138 with HTTP; Sat, 12 Nov 2016 22:48:02 -0800 (PST) From: Jason Merrill Date: Sat, 12 Nov 2016 22:48:02 -0800 Message-ID: Subject: C++ PATCH for _Complex and constexpr To: gcc-patches List X-IsSubscribed: yes The constexpr code was treating __real/__imag as always producing an rvalue, which is incorrect. Tested x86_64-pc-linux-gnu, applying to trunk. commit b61d1ce84c2e66dde4662dab41ccd99dd360a02f Author: Jason Merrill Date: Sat Nov 12 10:45:14 2016 -0800 Fix constexpr lvalue use of __real and __imag. * constexpr.c (potential_constant_expression_1): REALPART_EXPR and IMAGPART_EXPR can be lvalues. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f75f0b0..739e902 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5105,6 +5105,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, #endif return RECUR (t, any); + case REALPART_EXPR: + case IMAGPART_EXPR: case COMPONENT_REF: case BIT_FIELD_REF: case ARROW_EXPR: @@ -5276,8 +5278,6 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, return true; /* fall through. */ - case REALPART_EXPR: - case IMAGPART_EXPR: case CONJ_EXPR: case SAVE_EXPR: case FIX_TRUNC_EXPR: diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C new file mode 100644 index 0000000..9a9291b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C @@ -0,0 +1,5 @@ +// { dg-do compile { target c++11 } } +// { dg-options "" } + +static _Complex int i; +static_assert (&__imag i == &__imag i, "");