From patchwork Wed Jan 26 19:40:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 80545 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 B4ADFB7124 for ; Thu, 27 Jan 2011 06:40:33 +1100 (EST) Received: (qmail 12521 invoked by alias); 26 Jan 2011 19:40:32 -0000 Received: (qmail 12502 invoked by uid 22791); 26 Jan 2011 19:40:31 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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; Wed, 26 Jan 2011 19:40:26 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0QJeP1Z004589 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 26 Jan 2011 14:40:25 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0QJeOa8007099 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 26 Jan 2011 14:40:24 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p0QJeNfv013308; Wed, 26 Jan 2011 20:40:23 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p0QJeNSk013306; Wed, 26 Jan 2011 20:40:23 +0100 Date: Wed, 26 Jan 2011 20:40:23 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Handle TRUTH_XOR_EXPR in potential_constant_expression_1 (PR c++/47476) Message-ID: <20110126194023.GL2724@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! The folder creates TRUTH_XOR_EXPR out of NE_EXPR with truth values on both sides, but potential_constant_expression_1 ICEs on it, as it doesn't handle that tree code. Fixed by treating it like other binary expressions (including NE_EXPR/EQ_EXPR if we know that the arguments aren't two pointers), bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2011-01-26 Jakub Jelinek PR c++/47476 * semantics.c (potential_constant_expression_1): Handle TRUTH_XOR_EXPR. * g++.dg/cpp0x/pr47476.C: New test. Jakub --- gcc/cp/semantics.c.jj 2011-01-26 07:45:33.000000000 +0100 +++ gcc/cp/semantics.c 2011-01-26 17:32:42.863546187 +0100 @@ -7656,6 +7656,7 @@ potential_constant_expression_1 (tree t, case BIT_IOR_EXPR: case BIT_XOR_EXPR: case BIT_AND_EXPR: + case TRUTH_XOR_EXPR: case UNLT_EXPR: case UNLE_EXPR: case UNGT_EXPR: --- gcc/testsuite/g++.dg/cpp0x/pr47476.C.jj 2011-01-26 17:38:24.493482589 +0100 +++ gcc/testsuite/g++.dg/cpp0x/pr47476.C 2011-01-26 17:38:59.189401986 +0100 @@ -0,0 +1,10 @@ +// PR c++/47476 +// { dg-do compile } +// { dg-options "-std=c++0x" } + +int +foo (int a, int b) +{ + const bool c ((a != 0) == (b != 26)); + return c; +}