From patchwork Thu Dec 6 14:30:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 204246 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 29D652C008E for ; Fri, 7 Dec 2012 01:31:09 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1355409070; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=y/YpsgshYtMmSo4n/k1UFDEXvu4=; b=X1gFWppwAb0g1xV HSnIe/jECB7gWNvCsRRja8802Vu5uWAZa9ri78vo6/qBKZRTh9L4usvHZldLYF+z hlW5ac7prnzthvq8DO7l7XC65Sw3nTn2DsK4aLRnu86ltI1UXDgEskfvcu9RBv/n vHccqHacvjs/2uErSM6Y6JTFzlcE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=rJmvdBAHdibTgS84ZkSdnJK6yBUxjyjF2NFdaN3l+a6e+jZ9yb57ohfBKaGpqS cbfj4BCcmEjkK4dG+9hAfZXxcxFwb0N8V5AX2QAaoIBZBDoAy8hDB6MVJiDc5eyX Dx6DMczuYTYxhHmE76KPRCOxssnocxf8/Ea9dTpw+4aUg=; Received: (qmail 24363 invoked by alias); 6 Dec 2012 14:31:04 -0000 Received: (qmail 24353 invoked by uid 22791); 6 Dec 2012 14:31:04 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_FN 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; Thu, 06 Dec 2012 14:30:56 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qB6EUqYN029132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 6 Dec 2012 09:30:56 -0500 Received: from zalov.redhat.com (vpn1-6-17.ams2.redhat.com [10.36.6.17]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qB6EUNWs012850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 Dec 2012 09:30:42 -0500 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qB6EUNmH022444; Thu, 6 Dec 2012 15:30:23 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qB6EUMol022443; Thu, 6 Dec 2012 15:30:22 +0100 Date: Thu, 6 Dec 2012 15:30:22 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: Re: [C++ PATCH] Fix build_noexcept_spec ICE (PR c++/54207) Message-ID: <20121206143022.GI2315@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20121206072442.GG2315@tucnak.redhat.com> <50C0A6AF.9090007@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <50C0A6AF.9090007@redhat.com> 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 On Thu, Dec 06, 2012 at 09:07:43AM -0500, Jason Merrill wrote: > These are the only two possibilities for a boolean INTEGER_CST, so > let's assert that it's false if it isn't true. > > You can then leave the 'else' on the "if (expr == error_mark_node)". > > And here you don't need to check the value at all unless in an assert. Ok, here is what I'm going to bootstrap/regtest then: 2012-12-06 Jakub Jelinek PR c++/54207 * except.c (build_noexcept_spec): Avoid direct comparison with boolean_true_node or boolean_false_node, instead use operand_equal_p and/or INTEGER_CST check. * pt.c (tsubst_exception_specification): Likewise. * typeck2.c (merge_exception_specifiers): Likewise. * g++.dg/cpp0x/noexcept18.C: New test. Jakub --- gcc/cp/pt.c.jj 2012-12-04 14:17:26.829197995 +0100 +++ gcc/cp/pt.c 2012-12-06 15:26:07.574298792 +0100 @@ -10840,7 +10840,7 @@ tsubst_exception_specification (tree fnt { /* A noexcept-specifier. */ tree expr = TREE_PURPOSE (specs); - if (expr == boolean_true_node || expr == boolean_false_node) + if (TREE_CODE (expr) == INTEGER_CST) new_specs = expr; else if (defer_ok) { --- gcc/cp/typeck2.c.jj 2012-12-04 14:17:26.882197630 +0100 +++ gcc/cp/typeck2.c 2012-12-06 15:16:28.091620326 +0100 @@ -1871,7 +1871,7 @@ merge_exception_specifiers (tree list, t /* If ADD is a deferred noexcept, we must have been called from process_subob_fn. For implicitly declared functions, we build up a list of functions to consider at instantiation time. */ - if (noex == boolean_true_node) + if (operand_equal_p (noex, boolean_true_node, 0)) noex = NULL_TREE; gcc_assert (fn && (!noex || is_overloaded_fn (noex))); noex = build_overload (fn, noex); --- gcc/cp/except.c.jj 2012-12-04 14:17:26.916197394 +0100 +++ gcc/cp/except.c 2012-12-06 15:23:46.169113297 +0100 @@ -1316,15 +1316,21 @@ build_noexcept_spec (tree expr, int comp LOOKUP_NORMAL); expr = cxx_constant_value (expr); } - if (expr == boolean_true_node) - return noexcept_true_spec; - else if (expr == boolean_false_node) - return noexcept_false_spec; + if (TREE_CODE (expr) == INTEGER_CST) + { + if (operand_equal_p (expr, boolean_true_node, 0)) + return noexcept_true_spec; + else + { + gcc_checking_assert (operand_equal_p (expr, boolean_false_node, 0)); + return noexcept_false_spec; + } + } else if (expr == error_mark_node) return error_mark_node; else { - gcc_assert (processing_template_decl || expr == error_mark_node + gcc_assert (processing_template_decl || TREE_CODE (expr) == DEFERRED_NOEXCEPT); return build_tree_list (expr, NULL_TREE); } --- gcc/testsuite/g++.dg/cpp0x/noexcept18.C.jj 2012-12-06 15:16:28.125619775 +0100 +++ gcc/testsuite/g++.dg/cpp0x/noexcept18.C 2012-12-06 15:16:28.125619775 +0100 @@ -0,0 +1,11 @@ +// PR c++/54207 +// { dg-do compile } +// { dg-options "-std=c++11" } + +typedef bool B; +constexpr B foo () { return true; } + +void +bar () noexcept (foo ()) +{ +}